本文整理匯總了Java中com.sun.javadoc.AnnotationDesc.elementValues方法的典型用法代碼示例。如果您正苦於以下問題:Java AnnotationDesc.elementValues方法的具體用法?Java AnnotationDesc.elementValues怎麽用?Java AnnotationDesc.elementValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sun.javadoc.AnnotationDesc
的用法示例。
在下文中一共展示了AnnotationDesc.elementValues方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processAnnotations
import com.sun.javadoc.AnnotationDesc; //導入方法依賴的package包/類
protected void processAnnotations(AnnotationDesc annotation, APIParameter apiParameter) {
if (annotation.annotationType().qualifiedName().startsWith("org.springframework.web.bind.annotation.")) {
for (ElementValuePair pair : annotation.elementValues()) {
if (pair.element().name().equals("value") || pair.element().name().equals("name")) {
if (pair.value() != null) {
apiParameter.setName(pair.value().toString().replace("\"", ""));
}
}
if (pair.element().name().equals("required")) {
if (pair.value().value().equals(true)) {
apiParameter.setParameterOccurs(ParameterOccurs.REQUIRED);
} else {
apiParameter.setParameterOccurs(ParameterOccurs.OPTIONAL);
}
}
}
}
}
示例2: getExportedPackage
import com.sun.javadoc.AnnotationDesc; //導入方法依賴的package包/類
private String getExportedPackage(ClassDoc clz) {
if (clz == null) {
return "";
}
PackageDoc cpkg = clz.containingPackage();
String pkg = cpkg == null ? "" : (cpkg.name());
for (AnnotationDesc a : clz.annotations()) {
if (a.annotationType().name().equals("ExportPackage")) {
for (AnnotationDesc.ElementValuePair p : a.elementValues()) {
pkg = p.value().toString();
break;
}
}
}
pkg = pkg.replaceAll("\"", "");
return pkg;
}
示例3: getAnnotationString
import com.sun.javadoc.AnnotationDesc; //導入方法依賴的package包/類
public String getAnnotationString(AnnotationDesc annot)
{
String result = "<span class='annotation'>";
String link = getItemLink(annot.annotationType());
result += link == null ? "@" + annot.annotationType().qualifiedName() : "<a href='" + link + "'>@" + annot.annotationType().name() + "</a>";
AnnotationDesc.ElementValuePair[] pairs = annot.elementValues();
if (pairs.length > 0)
{
result += " (";
for (int i = 0; i != pairs.length; i++)
{
if (i > 0)
{
result += ", ";
}
AnnotationDesc.ElementValuePair pair = pairs[i];
String link2 = getItemLink(pair.element().containingClass());
result += link2 == null ? pair.element().qualifiedName() : "<a href='" + link2 + "#" + getSignature(pair.element()) + "'>" + pair.element().name() + "</a>";
result += "=" + formatValue(pair.value());
}
result += ")";
}
return result + "</span>";
}
示例4: PSItemFieldDoc
import com.sun.javadoc.AnnotationDesc; //導入方法依賴的package包/類
private PSItemFieldDoc(PSItemDoc psItemDoc, FieldDoc fieldDoc, AnnotationDesc annotation) {
this.psItemDoc = psItemDoc;
this.reference = fieldDoc.name();
this.name = fieldDoc.constantValue().toString();
this.description = fieldDoc.commentText().replace('\n', ' ');
for (AnnotationDesc.ElementValuePair elementValuePair : annotation.elementValues()) {
if ("type".equals(elementValuePair.element().name())) {
Object typeValue = elementValuePair.value().value();
this.type = (Type) typeValue;
}
}
}
示例5: getFieldValidatorDesc
import com.sun.javadoc.AnnotationDesc; //導入方法依賴的package包/類
protected String getFieldValidatorDesc(FieldDoc fieldDoc) {
StringBuilder strBuilder = new StringBuilder();
for (AnnotationDesc annotationDesc : fieldDoc.annotations()) {
if (annotationDesc.annotationType().qualifiedTypeName().startsWith("org.hibernate.validator.constraints")
|| annotationDesc.annotationType().qualifiedTypeName().startsWith("javax.validation.constraints")
|| annotationDesc.annotationType().qualifiedTypeName().startsWith("lombok.NonNull")) {
strBuilder.append("@");
strBuilder.append(annotationDesc.annotationType().name());
if (annotationDesc.elementValues().length > 0) {
strBuilder.append("(");
boolean isFirstElement = true;
for (AnnotationDesc.ElementValuePair elementValuePair : annotationDesc.elementValues()) {
if (!isFirstElement) {
strBuilder.append(",");
}
strBuilder.append(elementValuePair.element().name());
strBuilder.append("=");
strBuilder.append(
net.winroad.wrdoclet.utils.Util.decodeUnicode(elementValuePair.value().toString()));
isFirstElement = false;
}
strBuilder.append(")");
}
strBuilder.append(" ");
}
}
return strBuilder.toString();
}
示例6: SubDomain
import com.sun.javadoc.AnnotationDesc; //導入方法依賴的package包/類
/**
* Instantiates a new Domain model.
*
*/
private SubDomain(final PackageDoc doc, final AnnotationDesc desc) {
this.codeName = doc.name();
for (AnnotationDesc.ElementValuePair member : desc.elementValues()) {
switch (member.element().name()) {
case "name":
this.title = getString(member);
break;
case "description":
this.description = getString(member);
break;
default:
}
}
this.links = Arrays.stream(doc.annotations())
.filter(ad -> isAnnotatedAsLink(ad.annotationType()))
.map(LinkModel::makeByLink)
.collect(Collectors.toList());
this.links.addAll(Arrays.stream(doc.annotations())
.filter(ad -> isAnnotatedAsLinks(ad.annotationType()))
.map(LinkModel::makeByLinks)
.flatMap(Collection::stream)
.collect(Collectors.toList())
);
this.concepts = new ArrayList<>();
}
示例7: ConceptModel
import com.sun.javadoc.AnnotationDesc; //導入方法依賴的package包/類
private ConceptModel(final ClassDoc doc, final AnnotationDesc desk) {
this.name = doc.simpleTypeName();
for (AnnotationDesc.ElementValuePair member : desk.elementValues()) {
switch (member.element().name()) {
case "name":
this.title = getString(member);
break;
case "description":
this.description = getString(member);
break;
default:
}
}
}
示例8: LinkModel
import com.sun.javadoc.AnnotationDesc; //導入方法依賴的package包/類
private LinkModel(final AnnotationDesc desc) {
for (AnnotationDesc.ElementValuePair member : desc.elementValues()) {
switch (member.element().name()) {
case "related":
this.related = getString(member).toLowerCase();
break;
case "label":
this.label = getString(member);
break;
default:
}
}
}
示例9: makeByLinks
import com.sun.javadoc.AnnotationDesc; //導入方法依賴的package包/類
private static List<LinkModel> makeByLinks(final AnnotationDesc desc) {
final ArrayList<LinkModel> result = new ArrayList<>();
for (AnnotationDesc.ElementValuePair member : desc.elementValues())
if ("value".equals(member.element().name())) {
Arrays.stream((AnnotationValue[]) member.value().value())
.map(AnnotationValue::value)
.map(AnnotationDesc.class::cast)
.forEach(ad -> result.add(new LinkModel(ad)));
}
return result;
}
示例10: getAnnotationValue
import com.sun.javadoc.AnnotationDesc; //導入方法依賴的package包/類
public static Object getAnnotationValue(final AnnotationDesc annotation, final String name) {
for (final ElementValuePair elementValuePair : annotation.elementValues()) {
if (elementValuePair.element().name().equals(name)) {
return elementValuePair.value().value();
}
}
return null;
}
示例11: toAnnotationNode
import com.sun.javadoc.AnnotationDesc; //導入方法依賴的package包/類
/**
*
* @return an "annotation" XML node for the annotation.
*/
private static XMLNode toAnnotationNode(AnnotationDesc annotation) {
if (annotation == null) return null;
XMLNode node = new XMLNode("annotation");
node.attribute("name", annotation.annotationType().name());
for (ElementValuePair pair : annotation.elementValues()) {
node.child(toPairNode(pair));
}
return node;
}
示例12: getExportedName
import com.sun.javadoc.AnnotationDesc; //導入方法依賴的package包/類
private String getExportedName(MethodDoc cd) {
String ename = cd.name();
for (AnnotationDesc a : cd.annotations()) {
if (a.annotationType().name().equals("Export")) {
for (AnnotationDesc.ElementValuePair p : a.elementValues()) {
ename = p.value().toString();
break;
}
}
}
return ename.replaceAll("\"", "");
}
示例13: getAnnotationDescValue
import com.sun.javadoc.AnnotationDesc; //導入方法依賴的package包/類
public static Object getAnnotationDescValue(AnnotationDesc annotationDesc, String name) {
for (ElementValuePair elementValuePair : annotationDesc.elementValues()) {
if (elementValuePair.element().name().equals(name)) {
return elementValuePair.value().value();
}
};
return null;
}
示例14: getValue
import com.sun.javadoc.AnnotationDesc; //導入方法依賴的package包/類
/**
* Get annotation value.
*
* @returns the value or <code>null</code> if key was not found.
*/
private String getValue(AnnotationDesc annotation, String key) {
for (ElementValuePair pair : annotation.elementValues()) {
if (pair.element().name().equals(key)) {
// double call to value is correct as this returns the actual
// value object.
return pair.value().value().toString();
}
}
return null;
}
示例15: getElementValue
import com.sun.javadoc.AnnotationDesc; //導入方法依賴的package包/類
public static List<String> getElementValue(AnnotationDesc annotation, String key) {
for (AnnotationDesc.ElementValuePair element : annotation.elementValues())
if (element.element().name().equals(key)) {
return resolveAnnotationValue(element.value());
}
return emptyList();
}