/** * Return the annotations associated with the specific method/constructor parameter. */ public Annotation[] getParameterAnnotations() { Annotation[] paramAnns = this.parameterAnnotations; if (paramAnns == null) { Annotation[][] annotationArray = this.executable.getParameterAnnotations(); int index = this.parameterIndex; if (this.executable instanceof Constructor && ClassUtils.isInnerClass(this.executable.getDeclaringClass()) && annotationArray.length == this.executable.getParameterCount() - 1) { // Bug in javac in JDK <9: annotation array excludes enclosing instance parameter // for inner classes, so access it with the actual parameter index lowered by 1 index = this.parameterIndex - 1; } paramAnns = (index >= 0 && index < annotationArray.length ? adaptAnnotationArray(annotationArray[index]) : EMPTY_ANNOTATION_ARRAY); this.parameterAnnotations = paramAnns; } return paramAnns; }
Executable executable = parameter.getDeclaringExecutable(); if (executable instanceof Constructor && ClassUtils.isInnerClass(executable.getDeclaringClass()) && executable.getParameterAnnotations().length == executable.getParameterCount() - 1) {
/** * Return the annotations associated with the specific method/constructor parameter. */ public Annotation[] getParameterAnnotations() { Annotation[] paramAnns = this.parameterAnnotations; if (paramAnns == null) { Annotation[][] annotationArray = this.executable.getParameterAnnotations(); int index = this.parameterIndex; if (this.executable instanceof Constructor && ClassUtils.isInnerClass(this.executable.getDeclaringClass()) && annotationArray.length == this.executable.getParameterCount() - 1) { // Bug in javac in JDK <9: annotation array excludes enclosing instance parameter // for inner classes, so access it with the actual parameter index lowered by 1 index = this.parameterIndex - 1; } paramAnns = (index >= 0 && index < annotationArray.length ? adaptAnnotationArray(annotationArray[index]) : EMPTY_ANNOTATION_ARRAY); this.parameterAnnotations = paramAnns; } return paramAnns; }
&& executable.getParameterAnnotations().length == executable.getParameterCount() - 1) {
@Override public Object compute(MetaAccessProvider metaAccess, ResolvedJavaField original, ResolvedJavaField annotated, Object receiver) { Executable executable = (Executable) receiver; return executable.getParameterAnnotations(); } }
private boolean detectParameterConstraints(Executable c) { for (Annotation[] aa : c.getParameterAnnotations()) for (Annotation a : aa) { final Class<? extends Annotation> annType = a.annotationType(); if (knownConstraints.contains(annType)) { return true; } // detect custom annotations for (Annotation annOnAnnType : annType.getAnnotations()) { final Class<? extends Annotation> annTypeOnAnnType = annOnAnnType.annotationType(); if (Constraint.class == annTypeOnAnnType) { knownConstraints.add(annType); return true; } } } return false; } }
/** * Return the annotations associated with the specific method/constructor parameter. */ public Annotation[] getParameterAnnotations() { Annotation[] paramAnns = this.parameterAnnotations; if (paramAnns == null) { Annotation[][] annotationArray = this.executable.getParameterAnnotations(); if (this.parameterIndex >= 0 && this.parameterIndex < annotationArray.length) { paramAnns = adaptAnnotationArray(annotationArray[this.parameterIndex]); } else { paramAnns = new Annotation[0]; } this.parameterAnnotations = paramAnns; } return paramAnns; }
public <T extends Annotation> Optional<T> findParameter(Injectee injectee, Class<T> type) { AnnotatedElement parent = injectee.getParent(); Optional<T> annotation; if (parent instanceof Field) { Field field = (Field) parent; annotation = Optional.ofNullable(field.getAnnotation(type)); } else { Executable executable = (Executable) parent; Annotation[][] annotations = executable.getParameterAnnotations(); Annotation[] params = annotations[injectee.getPosition()]; annotation = Stream.of(params) .parallel() .filter(p -> type.equals(p.annotationType())) .map(p -> (T) p) .findFirst(); } return annotation; }
private static List<Class<?>> getExecutableParameterTypes(Executable executable, Weld weld, boolean explicitInjection) { List<Class<?>> types = new ArrayList<>(); if (explicitInjection) { Annotation[][] paramAnns = executable.getParameterAnnotations(); Class<?>[] paramTypes = executable.getParameterTypes(); for (int c = 0; c < paramAnns.length; ++c) { if (stream(paramAnns[c]).anyMatch(ann -> isAnnotated(ann.annotationType(), Qualifier.class) || isAnnotated(ann.annotationType(), NormalScope.class))) { weld.addBeanClass(paramTypes[c]); types.add(paramTypes[c]); } } } else { for (Class<?> paramType : executable.getParameterTypes()) { weld.addBeanClass(paramType); types.add(paramType); } } return types; }
private static List<Class<?>> getExecutableParameterTypes(Executable executable, Weld weld, boolean explicitInjection) { List<Class<?>> types = new ArrayList<>(); if (explicitInjection) { Annotation[][] paramAnns = executable.getParameterAnnotations(); Class<?>[] paramTypes = executable.getParameterTypes(); for (int c = 0; c < paramAnns.length; ++c) { if (stream(paramAnns[c]).anyMatch(ann -> isAnnotated(ann.annotationType(), Qualifier.class) || isAnnotated(ann.annotationType(), NormalScope.class))) { weld.addBeanClass(paramTypes[c]); types.add(paramTypes[c]); } } } else { for (Class<?> paramType : executable.getParameterTypes()) { weld.addBeanClass(paramType); types.add(paramType); } } return types; }
private Provider<?>[] getParamProviders(final Key<?> key, final Executable executable, final Set<Key<?>> chain) { final Class<?>[] paramClasses = executable.getParameterTypes(); final Type[] paramTypes = executable.getGenericParameterTypes(); final Annotation[][] annotations = executable.getParameterAnnotations(); final Provider<?>[] result = new Provider<?>[paramTypes.length]; for (int i = 0; i < paramTypes.length; ++i) { result[i] = getParamProvider(key, paramClasses[i], paramTypes[i], annotations[i], chain); } return result; }
/** * Return the annotations associated with the specific method/constructor parameter. */ public Annotation[] getParameterAnnotations() { Annotation[] paramAnns = this.parameterAnnotations; if (paramAnns == null) { Annotation[][] annotationArray = this.executable.getParameterAnnotations(); int index = this.parameterIndex; if (this.executable instanceof Constructor && ClassUtils.isInnerClass(this.executable.getDeclaringClass()) && annotationArray.length == this.executable.getParameterCount() - 1) { // Bug in javac in JDK <9: annotation array excludes enclosing instance parameter // for inner classes, so access it with the actual parameter index lowered by 1 index = this.parameterIndex - 1; } paramAnns = (index >= 0 && index < annotationArray.length ? adaptAnnotationArray(annotationArray[index]) : EMPTY_ANNOTATION_ARRAY); this.parameterAnnotations = paramAnns; } return paramAnns; }
Executable executable = parameter.getDeclaringExecutable(); if (executable instanceof Constructor && ClassUtils.isInnerClass(executable.getDeclaringClass()) && executable.getParameterAnnotations().length == executable.getParameterCount() - 1) {
Executable executable = parameter.getDeclaringExecutable(); if (executable instanceof Constructor && ClassUtils.isInnerClass(executable.getDeclaringClass()) && executable.getParameterAnnotations().length == executable.getParameterCount() - 1) {