Class OperationIdIdentificationStrategy
- All Implemented Interfaces:
EndpointIdentificationStrategy
EndpointIdentificationStrategy that uses information in the endpoint's context to determine an endpoint ID.
An endpoint ID is determined as a value of "operationId" attribute of the Operation annotation extracted from method of the endpoint controller class.
In case there is no Operation annotation or "operationId" 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 Operation is not present the empty Optional is returned.
The strategy caches the found endpoint IDs for methods, so the IDs are not recalculated.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindEndpointId(EndpointContextData endpointContextData) Finds the endpoint ID based on method attribute of the endpoint's context data.protected StringformatEndpointId(String endpointMethodName, String requestMethodName) Formats endpoint ID basing on name of HTTP request method and name of endpoint method name.protected StringgetByApiOperationNickname(Method endpointMethod) Gets an endpoint ID as a "operationId" attribute ofOperationannotation of the given endpoint method.protected StringgetByEndpointMethod(Method endpointMethod) Gets an endpoint ID based on endpoint method information.protected StringgetByRequestMethod(org.springframework.web.bind.annotation.RequestMapping requestMapping, Method endpointMethod) Gets endpoint ID basing onRequestMappingannotation and endpoint method name.protected StringgetRequestMethodName(org.springframework.web.bind.annotation.RequestMapping requestMapping) Gets name of HTTP request method from givenRequestMappingannotation.
-
Constructor Details
-
OperationIdIdentificationStrategy
public OperationIdIdentificationStrategy()
-
-
Method Details
-
findEndpointId
Finds the endpoint ID based on method attribute of the endpoint's context data.Returns the empty
Optionalin case the method is not specified or theRequestMappingmethod annotation is not present or it is unable to determine the endpoint ID.Throws
IllegalArgumentExceptionin case theendpointContextDataargument is null.- Specified by:
findEndpointIdin interfaceEndpointIdentificationStrategy- Parameters:
endpointContextData- endpoint's context data- Returns:
Optionalwith endpoint ID or empty result
-
getByEndpointMethod
Gets an endpoint ID based on endpoint method information. If theRequestMappingannotation is not present, the method returns null value.- Parameters:
endpointMethod- endpoint method- Returns:
- endpoint identifier or null
-
getByApiOperationNickname
Gets an endpoint ID as a "operationId" attribute ofOperationannotation of the given endpoint method.Returns the endpoint ID or null if the
Operationannotation or "operationId" attribute is not present.- Parameters:
endpointMethod- endpoint method- Returns:
- endpoint ID or null
-
getByRequestMethod
protected String getByRequestMethod(org.springframework.web.bind.annotation.RequestMapping requestMapping, Method endpointMethod) Gets endpoint ID basing onRequestMappingannotation and endpoint method name.Returns endpoint ID in the "{endpointMethodName}Using{requestMethodName}" format.
The name of HTTP request method is determined based on
RequestMappingannotation.In case there is no request method specified then the GET request method is taken.
- Parameters:
requestMapping- request mapping annotation objectendpointMethod- endpoint method- Returns:
- endpoint ID
-
getRequestMethodName
protected String getRequestMethodName(org.springframework.web.bind.annotation.RequestMapping requestMapping) Gets name of HTTP request method from givenRequestMappingannotation.The
RequestMethod.GETname is returned in case the "method" attribute is not present in theRequestMappingannotation.- Parameters:
requestMapping-RequestMappingannotation- Returns:
- name of HTTP request method
-
formatEndpointId
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 methodrequestMethodName- name of HTTP request method- Returns:
- formatted endpoint ID
-
getEndpointIdCache
-