本文整理汇总了Java中javax.lang.model.element.AnnotationValue.accept方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationValue.accept方法的具体用法?Java AnnotationValue.accept怎么用?Java AnnotationValue.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.lang.model.element.AnnotationValue
的用法示例。
在下文中一共展示了AnnotationValue.accept方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveAnnotationValue
import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked"})
private static <T> T resolveAnnotationValue(Class<T> expectedType, AnnotationValue value) {
if (value == null) {
return null;
}
Object unboxedValue = value.accept(new AnnotationValueVisitorImpl(), null);
if (unboxedValue != null) {
if (expectedType == TypeMirror.class && unboxedValue instanceof String) {
return null;
}
if (!expectedType.isAssignableFrom(unboxedValue.getClass())) {
throw new ClassCastException(unboxedValue.getClass().getName() + " not assignable from " + expectedType.getName());
}
}
return (T) unboxedValue;
}
示例2: getTypesFromAnnotation
import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
/**
* At compile time classes can not be obtained from annotation directly.
* This method extracts class information from annotation mirrors.
*
* @param element element annotated with {@link SqlSource} annotation
* @param isReq true for request, false for result parameters
* @return list of class names from {@link SqlSource} annotation
*/
private List<String> getTypesFromAnnotation(Element element, boolean isReq) {
TypeMirror sqlSourceTypeMirror = processingEnv.getElementUtils().getTypeElement(SqlSource.class.getName()).asType();
//method names from SqlSource annotation
String methodName = isReq ? "reqImpl" : "resImpl";
List<? extends AnnotationMirror> annotationMirrors = element.getAnnotationMirrors();
List<String> typeNames = new ArrayList<>();
for (AnnotationMirror am : annotationMirrors) {
if (!am.getAnnotationType().equals(sqlSourceTypeMirror)) {
continue;
}
for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : am.getElementValues().entrySet()) {
if (!methodName.equals(entry.getKey().getSimpleName().toString())) {
continue;
}
AnnotationValue impResVal = entry.getValue();
impResVal.accept(new SimpleAnnotationValueVisitor8<Void, Void>() {
@Override
public Void visitArray(List<? extends AnnotationValue> list, Void s) {
for (AnnotationValue val : list) {
TypeMirror typeMirror = (TypeMirror) val.getValue();
typeNames.add(typeMirror.toString());
}
return null;
}
}, null);
break;
}
}
return typeNames;
}
示例3: visitValue
import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
void visitValue(AnnotationValue value) {
value.accept(this, null);
}
示例4: isAnnotation
import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
public static boolean isAnnotation(final AnnotationValue annotationValue) {
return annotationValue.accept(IsAnnotationAnnotationValueVisitor.INSTANCE, null);
}
示例5: asAnnotation
import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
public static AnnotationMirror asAnnotation(final AnnotationValue annotationValue) {
return annotationValue.accept(AnnotationAnnotationValueVisitor.INSTANCE, null);
}
示例6: asString
import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
public static String asString(final AnnotationValue annotationValue) {
return annotationValue.accept(StringAnnotationValueVisitor.INSTANCE, null);
}
示例7: isArray
import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
public static boolean isArray(final AnnotationValue annotationValue) {
return annotationValue.accept(IsArrayAnnotationValueVisitor.INSTANCE, null);
}
示例8: asArray
import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
public static List<? extends AnnotationValue> asArray(final AnnotationValue annotationValue) {
return annotationValue.accept(ArrayAnnotationValueVisitor.INSTANCE, null);
}
示例9: asType
import javax.lang.model.element.AnnotationValue; //导入方法依赖的package包/类
public static TypeMirror asType(AnnotationValue annotationValue) {
return annotationValue.accept(TypeAnnotationValueVisitor.INSTANCE, null);
}