当前位置: 首页>>代码示例>>Java>>正文


Java AnnotationValueVisitor类代码示例

本文整理汇总了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);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:21,代码来源:Attribute.java

示例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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:Attribute.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:Attribute.java

示例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));
  }
}
 
开发者ID:facebook,项目名称:buck,代码行数:24,代码来源:TreeBackedAnnotationValue.java

示例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;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:35,代码来源:AnnotationValueImpl.java


注:本文中的javax.lang.model.element.AnnotationValueVisitor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。