List of usage examples for org.springframework.core.annotation AnnotationUtils synthesizeAnnotation
public static <A extends Annotation> A synthesizeAnnotation(A annotation, @Nullable AnnotatedElement annotatedElement)
From source file:com.github.ljtfreitas.restify.http.spring.contract.metadata.reflection.SpringWebJavaMethodParameterMetadata.java
public SpringWebJavaMethodParameterMetadata(java.lang.reflect.Parameter javaMethodParameter, Class<?> targetClassType) { this.type = JavaType.of(new JavaTypeResolver(targetClassType).parameterizedTypeOf(javaMethodParameter)); this.pathParameter = AnnotationUtils .synthesizeAnnotation(javaMethodParameter.getAnnotation(PathVariable.class), javaMethodParameter); this.headerParameter = AnnotationUtils .synthesizeAnnotation(javaMethodParameter.getAnnotation(RequestHeader.class), javaMethodParameter); this.bodyParameter = AnnotationUtils .synthesizeAnnotation(javaMethodParameter.getAnnotation(RequestBody.class), javaMethodParameter); this.queryParameter = AnnotationUtils .synthesizeAnnotation(javaMethodParameter.getAnnotation(RequestParam.class), javaMethodParameter); this.name = Optional.ofNullable(pathParameter).map(PathVariable::value).filter(s -> !s.trim().isEmpty()) .orElseGet(() -> Optional.ofNullable(headerParameter).map(RequestHeader::value) .filter(s -> !s.trim().isEmpty()) .orElseGet(() -> Optional.ofNullable(queryParameter).map(RequestParam::value) .filter(s -> !s.trim().isEmpty()) .orElseGet(() -> Optional.ofNullable(javaMethodParameter.getName()).orElseThrow( () -> new IllegalStateException("Could not get the name of the parameter " + javaMethodParameter))))); this.serializerType = SpringWebEndpointMethodParameterSerializer.of(this); }