for (final AnnotationDesc annotationDesc : annotations) { final AnnotationDocType annotationDocType = new AnnotationDocType(); final String typeName = annotationDesc.annotationType().qualifiedName(); annotationDocType.setAnnotationTypeName(typeName); for (final ElementValuePair elementValuePair : annotationDesc.elementValues()) {
public static AnnotationDesc getAnnotationDesc(ProgramElementDoc doc, Class<? extends Annotation> annotationClz) { for (AnnotationDesc annotationDesc : doc.annotations()) { if (annotationDesc.annotationType() .qualifiedTypeName().equals(annotationClz.getName())) { return annotationDesc; } } return null; }
static boolean hasAnnotation(MethodDoc methodDoc, Class cls) { for (AnnotationDesc annotationDesc : methodDoc.annotations()) { String qName = annotationDesc.annotationType().qualifiedTypeName(); if (qName.equals(cls.getCanonicalName())) { return true; } } return false; }
private static AnnotationDesc getAnnotation(ProgramElementDoc source, Class annotationType) { String name = annotationType.getName(); for (AnnotationDesc ad : source.annotations()) { if (ad.annotationType().qualifiedTypeName().equals(name)) { return ad; } } return null; }
private static AnnotationDesc getAnnotation(ProgramElementDoc source, Class annotationType) { String name = annotationType.getName(); for (AnnotationDesc ad : source.annotations()) { if (ad.annotationType().qualifiedTypeName().equals(name)) { return ad; } } return null; }
private static AnnotationDesc getAnnotation(ProgramElementDoc doc, String qualifiedName) { for (AnnotationDesc annotation : doc.annotations()) { if (annotation.annotationType().qualifiedName().equals(qualifiedName)) { return annotation; } } return null; }
/** * @return The annotation with the given <var>annotationType</var>, or {@code null} iff the <var>doc</var> is * not annotated with the <var>annotationType</var> */ @Nullable public static AnnotationDesc get(ProgramElementDoc doc, ClassDoc annotationType) { for (AnnotationDesc ad : doc.annotations()) { if (ad.annotationType().equals(annotationType)) return ad; } return null; }
/** * @return The annotation with the given <var>annotationType</var>, or {@code null} iff the <var>doc</var> is * not annotated with the <var>annotationType</var> */ @Nullable public static AnnotationDesc get(ProgramElementDoc doc, ClassDoc annotationType) { for (AnnotationDesc ad : doc.annotations()) { if (ad.annotationType().equals(annotationType)) return ad; } return null; }
private static AnnotationDesc getAnnotation(ProgramElementDoc doc, String qualifiedName) { for (AnnotationDesc annotation : doc.annotations()) { if (annotation.annotationType().qualifiedName().equals(qualifiedName)) { return annotation; } } return null; }
private static AnnotationDesc getAnnotation(ProgramElementDoc doc, String qualifiedName) { for (AnnotationDesc annotation : doc.annotations()) { if (annotation.annotationType().qualifiedName().equals(qualifiedName)) { return annotation; } } return null; }
private static AnnotationDesc getAnnotation(ProgramElementDoc elementDoc, Class<?> annoClass) { for (AnnotationDesc annoDesc : elementDoc.annotations()) { AnnotationTypeDoc typeDoc = annoDesc.annotationType(); if (typeDoc.typeName().equals(annoClass.getName()) || typeDoc.simpleTypeName().equals(annoClass.getSimpleName())) { return annoDesc; } } return null; }
public void writeClassAnnotiations(ClassDoc classDoc, StringBuilder sb) { AnnotationDesc[] annotations = classDoc.annotations(); for (AnnotationDesc annotation : annotations) { sb.append("\t").append(annotation.annotationType().name()).append(" : \n"); writeAnnotationTable(annotation, sb); } }
/** * Given an annotation, return true if it should be documented and false * otherwise. * * @param annotationDoc the annotation to check. * * @return true return true if it should be documented and false otherwise. */ public static boolean isDocumentedAnnotation(AnnotationTypeDoc annotationDoc) { AnnotationDesc[] annotationDescList = annotationDoc.annotations(); for (int i = 0; i < annotationDescList.length; i++) { if (annotationDescList[i].annotationType().qualifiedName().equals( java.lang.annotation.Documented.class.getName())){ return true; } } return false; }
private static Optional<String> summaryFromAnnotation(MethodDoc methodDoc) { return Stream.of(methodDoc.annotations()) .filter(annotation -> io.swagger.v3.oas.annotations.Operation.class.getName().equals(annotation.annotationType().qualifiedName())) .findFirst() .flatMap(a -> Stream.of(a.elementValues()) .filter(elementValuePair -> "summary".equals(elementValuePair.element().name())) .map(elementValuePair -> elementValuePair.value().value().toString()) .findFirst()); }
public static boolean hasAnnotation (ClassDoc classDoc) { if (classDoc.interfaces().length > 0) { for (AnnotationDesc annotationDesc : classDoc.annotations()) { if (annotationDesc.annotationType().qualifiedTypeName().equals(ApiMapping.class.getName())) { return true; } } } return false; } }
public void writeFieldAnnotiations(FieldDoc fieldDoc, StringBuilder sb) { AnnotationDesc[] annotations = fieldDoc.annotations(); for (AnnotationDesc annotation : annotations) { String fieldName = fieldDoc.name(); sb.append("\t").append(annotation.annotationType().name()).append(String.format(" [%s]", fieldName)); sb.append(" : \n"); writeAnnotationTable(annotation, sb); } }
/** * @return The annotation with the given simple (unqualified) type name, or {@code null} iff the <var>doc</var> is * not annotated with the <var>annotationTypeSimpleName</var> */ @Nullable public static AnnotationDesc get(ProgramElementDoc doc, String annotationTypeSimpleName) { for (AnnotationDesc ad : doc.annotations()) { if (ad.annotationType().simpleTypeName().equals(annotationTypeSimpleName)) return ad; } return null; }
public void writeAnnotationTable(AnnotationDesc annotation, StringBuilder sb) { AnnotationTypeElementDoc[] annotationElements = annotation.annotationType().elements(); if (annotationElements.length > 0) { Map<String, String> elementValueMap = createElementValueMap(annotation); sb.append(String.format("\t\t%1$20s %2$20s %3$20s\n", "NAME", "VALUE", "DEFAULT")); for (AnnotationTypeElementDoc annotationElement : annotationElements) { sb.append(String.format("\t\t%1$20s %2$20s %3$20s\n", annotationElement.name(), elementValueMap.get(annotationElement.name()), annotationElement.defaultValue())); } } }
/** * @return The annotation with the given simple (unqualified) type name, or {@code null} iff the <var>doc</var> is * not annotated with the <var>annotationTypeSimpleName</var> */ @Nullable public static AnnotationDesc get(ProgramElementDoc doc, String annotationTypeSimpleName) { for (AnnotationDesc ad : doc.annotations()) { if (ad.annotationType().simpleTypeName().equals(annotationTypeSimpleName)) return ad; } return null; }
public boolean isFunctionalInterface(AnnotationDesc annotationDesc) { return annotationDesc.annotationType().qualifiedName().equals( env.syms.functionalInterfaceType.toString()) && env.source.allowLambda(); }