/** * Reads the {@link Annotation} attribute's value from the given {@link AnnotatedElement}. * * @param annotatedElement must not be {@literal null}. * @return */ public Optional<Object> getValueFrom(AnnotatedElement annotatedElement) { Assert.notNull(annotatedElement, "Annotated element must not be null!"); Annotation annotation = annotatedElement.getAnnotation(annotationType); return Optional.ofNullable(annotation).map(it -> getValueFrom(annotation)); }
/** * Creates a new {@link AnnotationNamingMethodParameter} for the given {@link Method}'s parameter with the given * index. * * @param method must not be {@literal null}. * @param parameterIndex * @param attribute can be {@literal null} */ public AnnotationNamingMethodParameter(Method method, int parameterIndex, Optional<AnnotationAttribute> attribute) { super(method, parameterIndex); this.attribute = attribute; this.name = Lazy.of(() -> this.attribute.// flatMap(it -> it.getValueFrom(this).map(Object::toString)).// orElseGet(super::getParameterName)); }