本文整理汇总了Java中javax.lang.model.element.AnnotationValueVisitor类的典型用法代码示例。如果您正苦于以下问题:Java AnnotationValueVisitor类的具体用法?Java AnnotationValueVisitor怎么用?Java AnnotationValueVisitor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnnotationValueVisitor类属于javax.lang.model.element包,在下文中一共展示了AnnotationValueVisitor类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: accept
import javax.lang.model.element.AnnotationValueVisitor; //导入依赖的package包/类
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
if (value instanceof String)
return v.visitString((String) value, p);
if (value instanceof Integer) {
int i = (Integer) value;
switch (type.tag) {
case BOOLEAN: return v.visitBoolean(i != 0, p);
case CHAR: return v.visitChar((char) i, p);
case BYTE: return v.visitByte((byte) i, p);
case SHORT: return v.visitShort((short) i, p);
case INT: return v.visitInt(i, p);
}
}
switch (type.tag) {
case LONG: return v.visitLong((Long) value, p);
case FLOAT: return v.visitFloat((Float) value, p);
case DOUBLE: return v.visitDouble((Double) value, p);
}
throw new AssertionError("Bad annotation element value: " + value);
}
示例2: accept
import javax.lang.model.element.AnnotationValueVisitor; //导入依赖的package包/类
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
if (value instanceof String)
return v.visitString((String) value, p);
if (value instanceof Integer) {
int i = (Integer) value;
switch (type.getTag()) {
case BOOLEAN: return v.visitBoolean(i != 0, p);
case CHAR: return v.visitChar((char) i, p);
case BYTE: return v.visitByte((byte) i, p);
case SHORT: return v.visitShort((short) i, p);
case INT: return v.visitInt(i, p);
}
}
switch (type.getTag()) {
case LONG: return v.visitLong((Long) value, p);
case FLOAT: return v.visitFloat((Float) value, p);
case DOUBLE: return v.visitDouble((Double) value, p);
}
throw new AssertionError("Bad annotation element value: " + value);
}
示例3: accept
import javax.lang.model.element.AnnotationValueVisitor; //导入依赖的package包/类
@DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
if (value instanceof String)
return v.visitString((String) value, p);
if (value instanceof Integer) {
int i = (Integer) value;
switch (type.getTag()) {
case BOOLEAN: return v.visitBoolean(i != 0, p);
case CHAR: return v.visitChar((char) i, p);
case BYTE: return v.visitByte((byte) i, p);
case SHORT: return v.visitShort((short) i, p);
case INT: return v.visitInt(i, p);
}
}
switch (type.getTag()) {
case LONG: return v.visitLong((Long) value, p);
case FLOAT: return v.visitFloat((Float) value, p);
case DOUBLE: return v.visitDouble((Double) value, p);
}
throw new AssertionError("Bad annotation element value: " + value);
}
示例4: accept
import javax.lang.model.element.AnnotationValueVisitor; //导入依赖的package包/类
@Override
public <R, P> R accept(AnnotationValueVisitor<R, P> v, @Nullable P p) {
Object underlyingValue = underlyingAnnotationValue.getValue();
Object value = getValue();
if (underlyingValue.equals(value)) {
return underlyingAnnotationValue.accept(v, p);
}
if (value instanceof TreeBackedVariableElement) {
return v.visitEnumConstant((TreeBackedVariableElement) value, p);
} else if (value instanceof TypeMirror) {
return v.visitType((TypeMirror) value, p);
} else if (value instanceof TreeBackedAnnotationMirror) {
return v.visitAnnotation((TreeBackedAnnotationMirror) value, p);
} else if (value instanceof List) {
@SuppressWarnings("unchecked")
List<? extends AnnotationValue> valuesList = (List<? extends AnnotationValue>) value;
return v.visitArray(valuesList, p);
} else {
throw new IllegalStateException(String.format("Unexpected annotation value: %s", value));
}
}
示例5: accept
import javax.lang.model.element.AnnotationValueVisitor; //导入依赖的package包/类
@SuppressWarnings("unchecked") // Need to cast Object _value to a List<AnnotationValue>
@Override
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
switch (_kind) {
case TypeIds.T_boolean:
return v.visitBoolean((Boolean)_value, p);
case TypeIds.T_byte:
return v.visitByte((Byte)_value, p);
case TypeIds.T_char:
return v.visitChar((Character)_value, p);
case TypeIds.T_double:
return v.visitDouble((Double)_value, p);
case TypeIds.T_float:
return v.visitFloat((Float)_value, p);
case TypeIds.T_int:
return v.visitInt((Integer)_value, p);
case TypeIds.T_JavaLangString:
return v.visitString((String)_value, p);
case TypeIds.T_long:
return v.visitLong((Long)_value, p);
case TypeIds.T_short:
return v.visitShort((Short)_value, p);
case T_EnumConstant:
return v.visitEnumConstant((VariableElement)_value, p);
case T_ClassObject:
return v.visitType((TypeMirror)_value, p);
case T_AnnotationMirror:
return v.visitAnnotation((AnnotationMirror)_value, p);
case T_ArrayType:
return v.visitArray((List<AnnotationValue>)_value, p);
default:
return null;
}
}