javax.lang.model.util.SimpleAnnotationValueVisitor8 Java Examples

The following examples show how to use javax.lang.model.util.SimpleAnnotationValueVisitor8. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AutoUtils.java    From fastjgame with Apache License 2.0 5 votes vote down vote up
/**
 * 获取注解中引用的class对象的类型
 * eg:
 * {@code @AutoService(Processor.class)}
 * 返回的就是{@link javax.annotation.processing.Processor}
 */
public static TypeMirror getAnnotationValueTypeMirror(AnnotationValue annotationValue) {
    return annotationValue.accept(new SimpleAnnotationValueVisitor8<>() {
        @Override
        public TypeMirror visitType(TypeMirror t, Object o) {
            return t;
        }
    }, null);
}
 
Example #2
Source File: AnnotationValueUtil.java    From doma with Apache License 2.0 5 votes vote down vote up
public static Boolean toBoolean(AnnotationValue value) {
  if (value == null) {
    return null;
  }
  return value.accept(
      new SimpleAnnotationValueVisitor8<Boolean, Void>() {

        @Override
        public Boolean visitBoolean(boolean b, Void p) {
          return b;
        }
      },
      null);
}
 
Example #3
Source File: AnnotationValueUtil.java    From doma with Apache License 2.0 5 votes vote down vote up
public static Integer toInteger(AnnotationValue value) {
  if (value == null) {
    return null;
  }
  return value.accept(
      new SimpleAnnotationValueVisitor8<Integer, Void>() {

        @Override
        public Integer visitInt(int i, Void p) {
          return i;
        }
      },
      null);
}
 
Example #4
Source File: AnnotationValueUtil.java    From doma with Apache License 2.0 5 votes vote down vote up
public static Long toLong(AnnotationValue value) {
  if (value == null) {
    return null;
  }
  return value.accept(
      new SimpleAnnotationValueVisitor8<Long, Void>() {

        @Override
        public Long visitLong(long l, Void p) {
          return l;
        }
      },
      null);
}
 
Example #5
Source File: AnnotationValueUtil.java    From doma with Apache License 2.0 5 votes vote down vote up
public static String toString(AnnotationValue value) {
  if (value == null) {
    return null;
  }
  return value.accept(
      new SimpleAnnotationValueVisitor8<String, Void>() {

        @Override
        public String visitString(String s, Void p) {
          return s;
        }
      },
      null);
}
 
Example #6
Source File: AnnotationValueUtil.java    From doma with Apache License 2.0 5 votes vote down vote up
public static TypeMirror toType(AnnotationValue value) {
  if (value == null) {
    return null;
  }
  return value.accept(
      new SimpleAnnotationValueVisitor8<TypeMirror, Void>() {

        @Override
        public TypeMirror visitType(TypeMirror t, Void p) {
          return t;
        }
      },
      null);
}
 
Example #7
Source File: AnnotationValueUtil.java    From doma with Apache License 2.0 5 votes vote down vote up
public static VariableElement toEnumConstant(AnnotationValue value) {
  if (value == null) {
    return null;
  }
  return value.accept(
      new SimpleAnnotationValueVisitor8<VariableElement, Void>() {

        @Override
        public VariableElement visitEnumConstant(VariableElement c, Void p) {
          return c;
        }
      },
      null);
}
 
Example #8
Source File: AnnotationValueUtil.java    From doma with Apache License 2.0 5 votes vote down vote up
public static AnnotationMirror toAnnotation(AnnotationValue value) {
  if (value == null) {
    return null;
  }
  return value.accept(
      new SimpleAnnotationValueVisitor8<AnnotationMirror, Void>() {
        @Override
        public AnnotationMirror visitAnnotation(AnnotationMirror a, Void p) {
          return a;
        }
      },
      null);
}