コード例 #1
0
ファイル: Utils.java プロジェクト: orionhealth/jax-doclets
 public static Object getAnnotationValue(AnnotationDesc annotation, String name) {
   for (final ElementValuePair elementValuePair : annotation.elementValues()) {
     if (elementValuePair.element().name().equals(name)) {
       return elementValuePair.value().value();
     }
   }
   return null;
 }
コード例 #2
0
 /**
  * Put all annotation value key pairs into a map for easier lookup.
  *
  * @param ad
  * @param map
  */
 public static void mapAnnotation(AnnotationDesc ad, Map<String, Object> map) {
   ElementValuePair[] pairs = ad.elementValues();
   if (pairs != null) {
     for (ElementValuePair evp : pairs) {
       String name = evp.element().qualifiedName();
       Object value = evp.value().value();
       map.put(name, value);
     }
   }
 }
コード例 #3
0
 /**
  * Extract the request mapping data from the annotation.
  *
  * @param methodModel
  * @param ad
  */
 private static void extractRequestMapping(MethodModel methodModel, AnnotationDesc ad) {
   for (ElementValuePair pair : ad.elementValues()) {
     String pairName = pair.element().qualifiedName();
     if (REQUEST_MAPPING_VALUE.equals(pairName)) {
       String rawValue = pair.value().toString();
       if (rawValue != null) {
         methodModel.setUrl(rawValue.substring(1, rawValue.length() - 1));
       }
     } else if (REQUEST_MAPPING_METHOD.equals(pairName)) {
       String value = pair.value().toString();
       if (value != null) {
         int inxed = RequestMethod.class.getName().length();
         methodModel.setHttpType(value.substring(inxed + 1));
       }
     }
   }
 }
コード例 #4
0
 public InfoAnnotation(String clazzName, AnnotationDesc annotation) {
   items.put("package", new StringValue(clazzName));
   for (ElementValuePair elementValuePair : annotation.elementValues()) {
     AnnotationTypeElementDoc elementDoc = elementValuePair.element();
     AnnotationValue aValue = elementValuePair.value();
     String elementName = elementDoc.name();
     if (elementName.equals(AUTHOR)) {
       items.put(AUTHOR, new AnnotationSingleValue(aValue));
     } else if (elementName.equals(DISPLAY)) {
       items.put("display", new AnnotationSingleValue(aValue));
     } else if (elementName.equals(SUMMARY)) {
       items.put(SUMMARY, new AnnotationSingleValue(aValue));
     } else if (elementName.equals(SEND)) {
       items.put(SEND, new AnnotationSingleValue(aValue));
     } else if (elementName.equals(RECEIVE)) {
       items.put(RECEIVE, new AnnotationArrayValue(aValue));
     }
   }
 }