@Override public void process(Object annotation, OperationGenerator operationGenerator) { PatchMapping mappingAnnotation = (PatchMapping) annotation; Operation operation = operationGenerator.getOperation(); // path/value是等同的 this.processPath(mappingAnnotation.path(), operationGenerator); this.processPath(mappingAnnotation.value(), operationGenerator); this.processMethod(RequestMethod.PATCH, operationGenerator); this.processConsumes(mappingAnnotation.consumes(), operation); this.processProduces(mappingAnnotation.produces(), operation); if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) { throw new Error("HttpMethod must not both be empty in class and method"); } } }
ImmutableSet.copyOf(((PatchMapping) methodMapping).value())) : newArrayList( ImmutableSet.copyOf(((PatchMapping) methodMapping).path()));
extractMethodLevelMappings(elementUrls, concatValues(patchMapping.value(), patchMapping.path()), new RequestMethod[]{RequestMethod.PATCH});
@Override public void process(Object annotation, OperationGenerator operationGenerator) { PatchMapping mappingAnnotation = (PatchMapping) annotation; Operation operation = operationGenerator.getOperation(); // path/value是等同的 this.processPath(mappingAnnotation.path(), operationGenerator); this.processPath(mappingAnnotation.value(), operationGenerator); this.processMethod(RequestMethod.PATCH, operationGenerator); this.processConsumes(mappingAnnotation.consumes(), operation); this.processProduces(mappingAnnotation.produces(), operation); if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) { throw new Error("HttpMethod must not both be empty in class and method"); } } }
@Override public void process(Object annotation, OperationGenerator operationGenerator) { PatchMapping mappingAnnotation = (PatchMapping) annotation; Operation operation = operationGenerator.getOperation(); // path/value是等同的 this.processPath(mappingAnnotation.path(), operationGenerator); this.processPath(mappingAnnotation.value(), operationGenerator); this.processMethod(RequestMethod.PATCH, operationGenerator); this.processConsumes(mappingAnnotation.consumes(), operation); this.processProduces(mappingAnnotation.produces(), operation); if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) { throw new Error("HttpMethod must not both be empty in class and method"); } } }
public String[] getPath() { RequestMapping requestMapping = method.getAnnotation(RequestMapping.class); if (requestMapping != null) { return merge(requestMapping.path(), requestMapping.value()); } GetMapping getMapping = method.getAnnotation(GetMapping.class); if (getMapping != null) { return merge(getMapping.path(), getMapping.value()); } PostMapping postMapping = method.getAnnotation(PostMapping.class); if (postMapping != null) { return merge(postMapping.path(), postMapping.value()); } PutMapping putMapping = method.getAnnotation(PutMapping.class); if (putMapping != null) { return merge(putMapping.path(), putMapping.value()); } PatchMapping patchMapping = method.getAnnotation(PatchMapping.class); if (patchMapping != null) { return merge(patchMapping.path(), patchMapping.value()); } DeleteMapping deleteMapping = method.getAnnotation(DeleteMapping.class); if (deleteMapping != null) { return merge(deleteMapping.path(), deleteMapping.value()); } return null; }
static MappingInfo forAnnotation(Annotation a) { if (a instanceof RequestMapping) { return new MappingInfo<>((RequestMapping) a, (ann) -> select(ann.value(), ann.path()), RequestMapping::method); } else if (a instanceof GetMapping) { return new MappingInfo<>((GetMapping) a, (ann) -> select(ann.value(), ann.path()), (any) -> new RequestMethod[]{RequestMethod.GET}); } else if (a instanceof PostMapping) { return new MappingInfo<>((PostMapping) a, (ann) -> select(ann.value(), ann.path()), (any) -> new RequestMethod[]{RequestMethod.GET}); } else if (a instanceof PutMapping) { return new MappingInfo<>((PutMapping) a, (ann) -> select(ann.value(), ann.path()), (any) -> new RequestMethod[]{RequestMethod.GET}); } else if (a instanceof DeleteMapping) { return new MappingInfo<>((DeleteMapping) a, (ann) -> select(ann.value(), ann.path()), (any) -> new RequestMethod[]{RequestMethod.GET}); } else if (a instanceof PatchMapping) { return new MappingInfo<>((PatchMapping) a, (ann) -> select(ann.value(), ann.path()), (any) -> new RequestMethod[]{RequestMethod.GET}); } throw new IllegalArgumentException("Unknown annotation: " + a); }