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; }
/** * {@inheritDoc} */ public void addDefaultValueInfo(MemberDoc member, Content annotationDocTree) { if (((AnnotationTypeElementDoc) member).defaultValue() != null) { Content dt = HtmlTree.DT(writer.getResource("doclet.Default")); Content dl = HtmlTree.DL(dt); Content dd = HtmlTree.DD(new StringContent( ((AnnotationTypeElementDoc) member).defaultValue().toString())); dl.addContent(dd); annotationDocTree.addContent(dl); } }
/** * Parse the elements of an annotation * * @param annotationTypeElementDoc * A AnnotationTypeElementDoc instance * @return the annotation element node */ protected AnnotationElement parseAnnotationTypeElementDoc(AnnotationTypeElementDoc annotationTypeElementDoc) { AnnotationElement annotationElementNode = objectFactory.createAnnotationElement(); annotationElementNode.setName(annotationTypeElementDoc.name()); annotationElementNode.setQualified(annotationTypeElementDoc.qualifiedName()); annotationElementNode.setType(parseTypeInfo(annotationTypeElementDoc.returnType())); AnnotationValue value = annotationTypeElementDoc.defaultValue(); if (value != null) { annotationElementNode.setDefault(value.toString()); } return annotationElementNode; }
private Content annotationValueToContent(AnnotationValue annotationValue) { if (annotationValue.value() instanceof Type) { Type type = (Type) annotationValue.value(); if (type.asClassDoc() != null) { LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, LinkInfoImpl.Kind.ANNOTATION, type); linkInfo.label = new StringContent((type.asClassDoc().isIncluded() ? type.typeName() : type.qualifiedTypeName()) + type.dimension() + ".class"); return getLink(linkInfo); } else { return new StringContent(type.typeName() + type.dimension() + ".class"); } } else if (annotationValue.value() instanceof AnnotationDesc) { List<Content> list = getAnnotations(0, new AnnotationDesc[]{(AnnotationDesc) annotationValue.value()}, false); ContentBuilder buf = new ContentBuilder(); for (Content c: list) { buf.addContent(c); } return buf; } else if (annotationValue.value() instanceof MemberDoc) { return getDocLink(LinkInfoImpl.Kind.ANNOTATION, (MemberDoc) annotationValue.value(), ((MemberDoc) annotationValue.value()).name(), false); } else { return new StringContent(annotationValue.toString()); } }