/** * Returns the unique annotation names for annotations on each method parameter, if any parameters have * annotations, else returns null. * * Note that it is always faster to call {@link #getParameterInfo()} and get the parameter information from the * returned list of {@link MethodParameterInfo} objects, since this method calls that to compile its results. * * @return The method parameter annotation names, as an array of Strings, or null if no parameter annotations * are presest. */ public String[][] getParameterAnnotationNames() { final AnnotationInfo[][] paramAnnotationInfo = getParameterAnnotationInfo(); if (paramAnnotationInfo == null) { return null; } final String[][] paramAnnotationNames = new String[paramAnnotationInfo.length][]; for (int i = 0; i < paramAnnotationInfo.length; i++) { paramAnnotationNames[i] = AnnotationInfo.getUniqueAnnotationNamesSorted(paramAnnotationInfo[i]); } return paramAnnotationNames; }
private MethodInfo filterAnnotationsFor(MethodInfo method) { return new MethodInfo( method.getClassName(), method.getMethodName(), method.getAnnotationInfo() .stream() .filter(this::isVisibleAnnotation) .sorted() .collect(toList()), method.getModifiers(), method.getTypeDescriptorStr(), method.getTypeSignatureStr(), method.getParameterNames(), method.getParameterModifiers(), method.getParameterAnnotationInfo() ); }
@Override public Set<Method> getMethodsWithAnyParamAnnotated(Class clazz) { Map<String, ClassInfo> classInfos = scanResult.getClassNameToClassInfo(); Set<MethodIdentifier> methodIdentifiers = new HashSet<>(); for (ClassInfo classInfo : classInfos.values()){ for (MethodInfo methodInfo : classInfo.getMethodAndConstructorInfo()) { AnnotationInfo[][] parametersAnnotationInfo = methodInfo.getParameterAnnotationInfo(); if (parametersAnnotationInfo != null) for (AnnotationInfo[] oneParametersAnnotationInfo: parametersAnnotationInfo) { for (AnnotationInfo ai : oneParametersAnnotationInfo) { if (ai.getAnnotationType() == clazz) { methodIdentifiers.add(new MethodIdentifier(methodInfo.getClassName(), methodInfo.getMethodName(), methodInfo.getParameterTypeSignatures())); } } } } } Set<Method> methods = new HashSet<>(methodIdentifiers.size()); for (MethodIdentifier methodIdentifier : methodIdentifiers) { Class<?> classe = scanResult.classNameToClassRef(methodIdentifier.getClassName()); for (Method method : classe.getDeclaredMethods()) { if (methodIdentifier.matchesMethod(classe, method, scanResult)){ methods.add(method); } } } return methods; }
for (MethodInfo methodInfo : classInfo.getMethodAndConstructorInfo()) { if (methodInfo.isConstructor()) { AnnotationInfo[][] parametersAnnotationInfo = methodInfo.getParameterAnnotationInfo(); if (parametersAnnotationInfo != null) for (AnnotationInfo[] oneParametersAnnotationInfo: parametersAnnotationInfo) {