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()) { final NamedValueType namedValueType = new NamedValueType(); namedValueType.setName(elementValuePair.element().name());
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; }
ElementValuePair[] paramNames = annotationDesc.elementValues(); AnnotationValue[] statusCodes = (AnnotationValue[])paramNames[0].value().value(); if(statusCodes==null||statusCodes.length==0) { return statusCodeValue; } for(AnnotationValue statusCode:statusCodes) { AnnotationDesc anoDesc=(AnnotationDesc)statusCode.value(); if(anoDesc==null) { return statusCodeValue; } String key=(String)anoDesc.elementValues()[0].value().value(); String value=(String)anoDesc.elementValues()[1].value().value(); }
ContentBuilder annotation; for (int i = 0; i < descList.length; i++) { AnnotationTypeDoc annotationDoc = descList[i].annotationType(); LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, LinkInfoImpl.Kind.ANNOTATION, annotationDoc); AnnotationDesc.ElementValuePair[] pairs = descList[i].elementValues(); if (descList[i].isSynthesized()) { for (int j = 0; j < pairs.length; j++) { AnnotationValue annotationValue = pairs[j].value();
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 boolean isSupported( AnnotationDesc[] annotationDescs ) { for ( AnnotationDesc annotationDesc : annotationDescs ) { if ( annotationDesc.toString().contains( FACET_ANNOTATION ) ) { if ( annotationDesc.elementValues()[0].value().value().equals( UNSUPPORTED ) ) { return false; } } } return true; }
private AnnotationDesc getAnnotation(String qualifiedAnnotationType, boolean startsWith) { AnnotationDesc found = null; for (AnnotationDesc annotation : this.annotations) { try { if (startsWith) { if (annotation.annotationType().qualifiedTypeName().contains(qualifiedAnnotationType)) { found = annotation; break; } } else if (annotation.annotationType().qualifiedTypeName().equals(qualifiedAnnotationType)) { found = annotation; break; } } catch (RuntimeException e) { System.err.println(annotation + " has invalid javadoc: " + e.getClass() + ": " + e.getMessage()); } } return found; }
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()); }
private String getAnnotationValue(AnnotationDesc annotation, String... keys) { for (AnnotationDesc.ElementValuePair evp : annotation.elementValues()) { for (String key : keys) { if (evp.element().name().equals(key)) { String val = evp.value().value().toString(); val = val.trim(); return this.options.replaceVars(val); } } } 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; }
static Set<String> getMethodGroups(MethodDoc m) { Set<String> result = getGroups(m); result.addAll(getGroups(m.containingClass())); return result; } static Set<String> getGroups(ProgramElementDoc m) { Set<String> result = new HashSet<String>(); for(AnnotationDesc a: m.annotations()) { if (a.annotationType().name().equals("Test")) { for(ElementValuePair ev : a.elementValues()) { if (ev.element().name().equals("groups")) { String value = ev.value().toString(); StringTokenizer tokenizer = new StringTokenizer(value, "{}\", "); while (tokenizer.hasMoreElements()) { result.add(tokenizer.nextToken()); } } } } } return result; }
private void loadEvents() { AnnotationDesc eventsAnnotation = getAnnotation(classDoc, Events.class); if (eventsAnnotation == null) return; // Events has only a single attribute: value(), so we know its the first element // in the array. ElementValuePair pair = eventsAnnotation.elementValues()[0]; AnnotationValue annotationValue = pair.value(); AnnotationValue[] values = (AnnotationValue[]) annotationValue.value(); for (AnnotationValue eventValue : values) { String event = (String) eventValue.value(); int ws = event.indexOf(' '); String name = ws < 0 ? event : event.substring(0, ws); String description = ws < 0 ? "" : event.substring(ws + 1).trim(); events.put(name, description); } }
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; }
AnnotationTypeDoc annotationDoc = descList[i].annotationType(); if( !Util.isDocumentedAnnotation( annotationDoc ) ) annotation.append( getLink( linkInfo ) ); AnnotationDesc.ElementValuePair[] pairs = descList[i].elementValues(); if( pairs.length > 0 )
public Map<String, String> createElementValueMap(AnnotationDesc annotation) { AnnotationDesc.ElementValuePair[] elementValuePairs = annotation.elementValues(); Map<String, String> elementValueMap = new HashMap<>(); for (AnnotationDesc.ElementValuePair elementValuePair : elementValuePairs) { elementValueMap.put(elementValuePair.element().name(), elementValuePair.value().toString()); } return elementValueMap; }
/** * @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; }
AnnotationTypeDoc annotTypeInfo = annotationDesc.annotationType(); annotationInstanceNode.setName(annotTypeInfo.name()); annotationInstanceNode.setQualified(annotTypeInfo.qualifiedTypeName()); for (AnnotationDesc.ElementValuePair elementValuesPair : annotationDesc.elementValues()) { AnnotationArgument annotationArgumentNode = objectFactory.createAnnotationArgument(); annotationArgumentNode.setName(elementValuesPair.element().name());
private void loadEvents() { AnnotationDesc eventsAnnotation = getAnnotation(classDoc, Events.class); if (eventsAnnotation == null) return; // Events has only a single attribute: value(), so we know its the first element // in the array. ElementValuePair pair = eventsAnnotation.elementValues()[0]; AnnotationValue annotationValue = pair.value(); AnnotationValue[] values = (AnnotationValue[]) annotationValue.value(); for (AnnotationValue eventValue : values) { String event = (String) eventValue.value(); int ws = event.indexOf(' '); String name = ws < 0 ? event : event.substring(0, ws); String description = ws < 0 ? "" : event.substring(ws + 1).trim(); events.put(name, description); } }
/** * @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; }
if (annotationDesc.annotationType().qualifiedName().startsWith("restx.annotations.")) { Optional<Object> value = getAnnotationParamValue(annotationDesc.elementValues(), "value"); trace.trace(classDoc.name() + " > " + methodDoc.qualifiedName() + " > " + annotationDesc.annotationType().name()); trace.trace(asList(annotationDesc.elementValues()).toString()); trace.trace(methodDoc.commentText()); .setHttpMethod(annotationDesc.annotationType().name()) .setPath(String.valueOf(value.get())) .setNotes(methodDoc.commentText());