matches = scanResults.getClassNameToClassInfo().values().stream() .filter(ci -> ci.hasSuperclass(superClass.getName()) || ci.implementsInterface(superClass.getName())) .filter(ci -> ci.hasAnnotation(annotationClass.getName())).map(ClassInfo::getClassName) + "' and super class '" + superClass.getName() + "'"); } else { matches = scanResults.getClassNameToClassInfo().values().stream() .filter(ci -> ci.hasAnnotation(annotationClass.getName())).map(ClassInfo::getClassName) .collect(Collectors.toList());
@Override public Set<Field> getFieldsAnnotatedWith(Class clazz) { Map<String, ClassInfo> classInfos = scanResult.getClassNameToClassInfo(); Set<FieldIdentifier> fieldIdentifiers = new HashSet<>(); for (ClassInfo classInfo : classInfos.values()){ for (FieldInfo fieldInfo : classInfo.getFieldInfo()) { List<AnnotationInfo> fieldsAnnotationInfos = fieldInfo.getAnnotationInfo(); for (AnnotationInfo oneFieldAnnotation: fieldsAnnotationInfos) { if (oneFieldAnnotation.getAnnotationType() == clazz) { fieldIdentifiers.add(new FieldIdentifier(fieldInfo.getClassName(), fieldInfo.getFieldName(), fieldInfo.getType())); } } } } Set<Field> fields = new HashSet<>(fieldIdentifiers.size()); for (FieldIdentifier fieldIdentifier : fieldIdentifiers) { Class<?> classe = scanResult.classNameToClassRef(fieldIdentifier.getClassName()); for (Field field : classe.getDeclaredFields()) { if (fieldIdentifier.matchesField(classe, field)){ fields.add(field); } } } return fields; }
@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; }
@Override public Set<Constructor> getConstructorsWithAnyParamAnnotated(Class clazz) { Map<String, ClassInfo> classInfos = scanResult.getClassNameToClassInfo(); Set<MethodIdentifier> methodIdentifiers = new HashSet<>(); for (ClassInfo classInfo : classInfos.values()){
private void writeApis(ApiPrintWriter writer, ScanResult result) { Map<String, ClassInfo> allInfo = result.getClassNameToClassInfo(); result.getNamesOfAllClasses().forEach(className -> { if (className.contains(".internal.")) {