/** * Return whether the method/constructor is annotated with the given type. * @param annotationType the annotation type to look for * @since 4.3 * @see #getMethodAnnotation(Class) */ public <A extends Annotation> boolean hasMethodAnnotation(Class<A> annotationType) { return getAnnotatedElement().isAnnotationPresent(annotationType); }
/** * Return whether the method/constructor is annotated with the given type. * @param annotationType the annotation type to look for * @since 4.3 * @see #getMethodAnnotation(Class) */ public <A extends Annotation> boolean hasMethodAnnotation(Class<A> annotationType) { return getAnnotatedElement().isAnnotationPresent(annotationType); }
/** * Return the annotations associated with the target method/constructor itself. */ public Annotation[] getMethodAnnotations() { return adaptAnnotationArray(getAnnotatedElement().getAnnotations()); }
/** * Return the method/constructor annotation of the given type, if available. * @param annotationType the annotation type to look for * @return the annotation object, or {@code null} if not found */ @Nullable public <A extends Annotation> A getMethodAnnotation(Class<A> annotationType) { A annotation = getAnnotatedElement().getAnnotation(annotationType); return (annotation != null ? adaptAnnotation(annotation) : null); }
/** * Return the wrapped annotated element. * <p>Note: In case of a method/constructor parameter, this exposes * the annotations declared on the method or constructor itself * (i.e. at the method/constructor level, not at the parameter level). * Use {@link #getAnnotations()} to obtain parameter-level annotations in * such a scenario, transparently with corresponding field annotations. * @return the Field / Method / Constructor as AnnotatedElement */ public AnnotatedElement getAnnotatedElement() { return (this.field != null ? this.field : obtainMethodParameter().getAnnotatedElement()); }
private String getAttributeName(MethodParameter param) { return Optional .ofNullable(AnnotatedElementUtils.findMergedAnnotation(param.getAnnotatedElement(), ModelAttribute.class)) .filter(ann -> StringUtils.hasText(ann.value())) .map(ModelAttribute::value) .orElseGet(() -> Conventions.getVariableNameForParameter(param)); }
/** * Return the method/constructor annotation of the given type, if available. * @param annotationType the annotation type to look for * @return the annotation object, or {@code null} if not found */ @Nullable public <A extends Annotation> A getMethodAnnotation(Class<A> annotationType) { A annotation = getAnnotatedElement().getAnnotation(annotationType); return (annotation != null ? adaptAnnotation(annotation) : null); }
/** * Return the annotations associated with the target method/constructor itself. */ public Annotation[] getMethodAnnotations() { return adaptAnnotationArray(getAnnotatedElement().getAnnotations()); }
/** * Return the wrapped annotated element. * <p>Note: In case of a method/constructor parameter, this exposes * the annotations declared on the method or constructor itself * (i.e. at the method/constructor level, not at the parameter level). * Use {@link #getAnnotations()} to obtain parameter-level annotations in * such a scenario, transparently with corresponding field annotations. * @return the Field / Method / Constructor as AnnotatedElement */ public AnnotatedElement getAnnotatedElement() { return (this.field != null ? this.field : obtainMethodParameter().getAnnotatedElement()); }
protected boolean isLazy(DependencyDescriptor descriptor) { for (Annotation ann : descriptor.getAnnotations()) { Lazy lazy = AnnotationUtils.getAnnotation(ann, Lazy.class); if (lazy != null && lazy.value()) { return true; } } MethodParameter methodParam = descriptor.getMethodParameter(); if (methodParam != null) { Method method = methodParam.getMethod(); if (method == null || void.class == method.getReturnType()) { Lazy lazy = AnnotationUtils.getAnnotation(methodParam.getAnnotatedElement(), Lazy.class); if (lazy != null && lazy.value()) { return true; } } } return false; }
protected boolean isLazy(DependencyDescriptor descriptor) { for (Annotation ann : descriptor.getAnnotations()) { Lazy lazy = AnnotationUtils.getAnnotation(ann, Lazy.class); if (lazy != null && lazy.value()) { return true; } } MethodParameter methodParam = descriptor.getMethodParameter(); if (methodParam != null) { Method method = methodParam.getMethod(); if (method == null || void.class == method.getReturnType()) { Lazy lazy = AnnotationUtils.getAnnotation(methodParam.getAnnotatedElement(), Lazy.class); if (lazy != null && lazy.value()) { return true; } } } return false; }
/** * Return the annotations associated with the target method/constructor itself. */ public Annotation[] getMethodAnnotations() { return getAnnotatedElement().getAnnotations(); }
/** * Return the method/constructor annotation of the given type, if available. * @param annotationType the annotation type to look for * @return the annotation object, or <code>null</code> if not found */ @SuppressWarnings("unchecked") public <T extends Annotation> T getMethodAnnotation(Class<T> annotationType) { return getAnnotatedElement().getAnnotation(annotationType); }
/** * Return the wrapped annotated element. * <p>Note: In case of a method/constructor parameter, this exposes * the annotations declared on the method or constructor itself * (i.e. at the method/constructor level, not at the parameter level). * Use {@link #getAnnotations()} to obtain parameter-level annotations in * such a scenario, transparently with corresponding field annotations. * @return the Field / Method / Constructor as AnnotatedElement */ public AnnotatedElement getAnnotatedElement() { return (this.field != null ? this.field : this.methodParameter.getAnnotatedElement()); }
/** * Return whether the method/constructor is annotated with the given type. * @param annotationType the annotation type to look for * @since 4.3 * @see #getMethodAnnotation(Class) */ public <A extends Annotation> boolean hasMethodAnnotation(Class<A> annotationType) { return getAnnotatedElement().isAnnotationPresent(annotationType); }
/** * Return the method/constructor annotation of the given type, if available. * @param annotationType the annotation type to look for * @return the annotation object, or <code>null</code> if not found */ public <T extends Annotation> T getMethodAnnotation(Class<T> annotationType) { return getAnnotatedElement().getAnnotation(annotationType); }
/** * Return the annotations associated with the target method/constructor itself. */ public Annotation[] getMethodAnnotations() { return getAnnotatedElement().getAnnotations(); }
/** * Return the method/constructor annotation of the given type, if available. * @param annotationType the annotation type to look for * @return the annotation object, or {@code null} if not found */ @Nullable public <A extends Annotation> A getMethodAnnotation(Class<A> annotationType) { A annotation = getAnnotatedElement().getAnnotation(annotationType); return (annotation != null ? adaptAnnotation(annotation) : null); }
/** * Return the annotations associated with the target method/constructor itself. */ public Annotation[] getMethodAnnotations() { return adaptAnnotationArray(getAnnotatedElement().getAnnotations()); }
/** * Return the annotations associated with the target method/constructor itself. */ public Annotation[] getMethodAnnotations() { return adaptAnnotationArray(getAnnotatedElement().getAnnotations()); }