Class OperationIdIdentificationStrategy

  • All Implemented Interfaces:
    EndpointIdentificationStrategy

    public class OperationIdIdentificationStrategy
    extends java.lang.Object
    implements EndpointIdentificationStrategy
    Implementation of EndpointIdentificationStrategy that uses information in the endpoint's context to determine an endpoint ID.

    An endpoint ID is determined as a value of "nickname" attribute of the ApiOperation annotation extracted from method of the endpoint controller class.

    In case there is no ApiOperation annotation or "nickname" attribute, then the endpoint ID is determined by name of the endpoint method and the name of the HTTP request method specified by the RequestMapping annotation.

    If the RequestMapping or ApiOperation is not present the empty Optional is returned.

    The strategy caches the found endpoint IDs for methods, so the IDs are not recalculated.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<java.lang.String> findEndpointId​(EndpointContextData endpointContextData)
      Finds the endpoint ID based on method attribute of the endpoint's context data.
      protected java.lang.String formatEndpointId​(java.lang.String endpointMethodName, java.lang.String requestMethodName)
      Formats endpoint ID basing on name of HTTP request method and name of endpoint method name.
      protected java.lang.String getByApiOperationNickname​(java.lang.reflect.Method endpointMethod)
      Gets an endpoint ID as a "nickname" attribute of ApiOperation annotation of the given endpoint method.
      protected java.lang.String getByEndpointMethod​(java.lang.reflect.Method endpointMethod)
      Gets an endpoint ID based on endpoint method information.
      protected java.lang.String getByRequestMethod​(org.springframework.web.bind.annotation.RequestMapping requestMapping, java.lang.reflect.Method endpointMethod)
      Gets endpoint ID basing on RequestMapping annotation and endpoint method name.
      protected java.util.Map<java.lang.reflect.Method,​java.lang.String> getEndpointIdCache()  
      protected java.lang.String getRequestMethodName​(org.springframework.web.bind.annotation.RequestMapping requestMapping)
      Gets name of HTTP request method from given RequestMapping annotation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OperationIdIdentificationStrategy

        public OperationIdIdentificationStrategy()
    • Method Detail

      • findEndpointId

        public java.util.Optional<java.lang.String> findEndpointId​(EndpointContextData endpointContextData)
        Finds the endpoint ID based on method attribute of the endpoint's context data.

        Returns the empty Optional in case the method is not specified or the RequestMapping method annotation is not present or it is unable to determine the endpoint ID.

        Throws IllegalArgumentException in case the endpointContextData argument is null.

        Specified by:
        findEndpointId in interface EndpointIdentificationStrategy
        Parameters:
        endpointContextData - endpoint's context data
        Returns:
        Optional with endpoint ID or empty result
      • getByEndpointMethod

        protected java.lang.String getByEndpointMethod​(java.lang.reflect.Method endpointMethod)
        Gets an endpoint ID based on endpoint method information. If the RequestMapping annotation is not present, the method returns null value.
        Parameters:
        endpointMethod - endpoint method
        Returns:
        endpoint identifier or null
      • getByApiOperationNickname

        protected java.lang.String getByApiOperationNickname​(java.lang.reflect.Method endpointMethod)
        Gets an endpoint ID as a "nickname" attribute of ApiOperation annotation of the given endpoint method.

        Returns the endpoint ID or null if the ApiOperation annotation or "nickname" attribute is not present.

        Parameters:
        endpointMethod - endpoint method
        Returns:
        endpoint ID or null
      • getByRequestMethod

        protected java.lang.String getByRequestMethod​(org.springframework.web.bind.annotation.RequestMapping requestMapping,
                                                      java.lang.reflect.Method endpointMethod)
        Gets endpoint ID basing on RequestMapping annotation and endpoint method name.

        Returns endpoint ID in the "{endpointMethodName}Using{requestMethodName}" format.

        The name of HTTP request method is determined based on RequestMapping annotation.

        In case there is no request method specified then the GET request method is taken.

        Parameters:
        requestMapping - request mapping annotation object
        endpointMethod - endpoint method
        Returns:
        endpoint ID
      • getRequestMethodName

        protected java.lang.String getRequestMethodName​(org.springframework.web.bind.annotation.RequestMapping requestMapping)
        Gets name of HTTP request method from given RequestMapping annotation.

        The RequestMethod.GET name is returned in case the "method" attribute is not present in the RequestMapping annotation.

        Parameters:
        requestMapping - RequestMapping annotation
        Returns:
        name of HTTP request method
      • formatEndpointId

        protected java.lang.String formatEndpointId​(java.lang.String endpointMethodName,
                                                    java.lang.String requestMethodName)
        Formats endpoint ID basing on name of HTTP request method and name of endpoint method name.

        Returns endpoint ID in the "{endpointMethodName}Using{requestMethodName}" format.

        Parameters:
        endpointMethodName - name of endpoint method
        requestMethodName - name of HTTP request method
        Returns:
        formatted endpoint ID
      • getEndpointIdCache

        protected java.util.Map<java.lang.reflect.Method,​java.lang.String> getEndpointIdCache()