Example usage for org.springframework.web.servlet.mvc.condition RequestMethodsRequestCondition getMethods

List of usage examples for org.springframework.web.servlet.mvc.condition RequestMethodsRequestCondition getMethods

Introduction

In this page you can find the example usage for org.springframework.web.servlet.mvc.condition RequestMethodsRequestCondition getMethods.

Prototype

public Set<RequestMethod> getMethods() 

Source Link

Document

Returns all RequestMethod RequestMethods contained in this condition.

Usage

From source file:springfox.documentation.spring.web.readers.operation.ApiOperationReader.java

@Override
//  @Cacheable(value = "operations", keyGenerator = OperationsKeyGenerator.class)
public List<Operation> read(RequestMappingContext outerContext) {

    RequestMappingInfo requestMappingInfo = outerContext.getRequestMappingInfo();
    String requestMappingPattern = outerContext.getRequestMappingPattern();
    RequestMethodsRequestCondition requestMethodsRequestCondition = requestMappingInfo.getMethodsCondition();
    List<Operation> operations = newArrayList();

    Set<RequestMethod> requestMethods = requestMethodsRequestCondition.getMethods();
    Set<RequestMethod> supportedMethods = supportedMethods(requestMethods);

    //Setup response message list
    Integer currentCount = 0;/*w w  w  . j  a v a 2s .  c  o  m*/
    for (RequestMethod httpRequestMethod : supportedMethods) {
        OperationContext operationContext = new OperationContext(new OperationBuilder(nameGenerator),
                httpRequestMethod, outerContext.getHandlerMethod(), currentCount, requestMappingInfo,
                outerContext.getDocumentationContext(), requestMappingPattern);

        Operation operation = pluginsManager.operation(operationContext);
        if (!operation.isHidden()) {
            operations.add(operation);
            currentCount++;
        }
    }
    Collections.sort(operations, outerContext.operationOrdering());

    return operations;
}