示例#1
0
 public static FunctionMirror newInstance(ExecutableElement method, ProcessingEnvironment env) {
   assertNotNull(env);
   AnnotationMirror annotationMirror =
       ElementUtil.getAnnotationMirror(method, Function.class, env);
   if (annotationMirror == null) {
     return null;
   }
   FunctionMirror result = new FunctionMirror(annotationMirror, method.getSimpleName().toString());
   for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry :
       env.getElementUtils().getElementValuesWithDefaults(annotationMirror).entrySet()) {
     String name = entry.getKey().getSimpleName().toString();
     AnnotationValue value = entry.getValue();
     if ("catalog".equals(name)) {
       result.catalog = value;
     } else if ("schema".equals(name)) {
       result.schema = value;
     } else if ("name".equals(name)) {
       result.name = value;
     } else if ("queryTimeout".equals(name)) {
       result.queryTimeout = value;
     } else if ("mapKeyNaming".equals(name)) {
       result.mapKeyNaming = value;
     } else if ("ensureResultMapping".equals(name)) {
       result.ensureResultMapping = value;
     }
   }
   return result;
 }
示例#2
0
 public static EntityMirror newInstance(TypeElement clazz, ProcessingEnvironment env) {
   assertNotNull(env);
   AnnotationMirror annotationMirror = ElementUtil.getAnnotationMirror(clazz, Entity.class, env);
   if (annotationMirror == null) {
     return null;
   }
   EntityMirror result = new EntityMirror(annotationMirror);
   for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry :
       env.getElementUtils().getElementValuesWithDefaults(annotationMirror).entrySet()) {
     String name = entry.getKey().getSimpleName().toString();
     AnnotationValue value = entry.getValue();
     if ("listener".equals(name)) {
       result.listener = value;
     } else if ("naming".equals(name)) {
       result.naming = value;
     } else if ("immutable".equals(name)) {
       result.immutable = value;
     }
   }
   return result;
 }