javax.lang.model.element.AnnotationValueVisitor Java Examples

The following examples show how to use javax.lang.model.element.AnnotationValueVisitor. 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: Attribute.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #2
Source File: Attribute.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@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);
}
 
Example #3
Source File: Attribute.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #4
Source File: Attribute.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #5
Source File: Attribute.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #6
Source File: Attribute.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #7
Source File: Attribute.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #8
Source File: Attribute.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #9
Source File: Attribute.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #10
Source File: SimpleAnnotationMirrorTest.java    From auto with Apache License 2.0 5 votes vote down vote up
private static AnnotationValue intValue(int value) {
  return new AnnotationValue() {
    @Override
    public Object getValue() {
      return value;
    }

    @Override
    public <R, P> R accept(AnnotationValueVisitor<R, P> annotationValueVisitor, P p) {
      return annotationValueVisitor.visitInt(value, p);
    }
  };
}
 
Example #11
Source File: AnnotationValueImpl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@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;
	}
}
 
Example #12
Source File: TurbineAnnotationMirror.java    From turbine with Apache License 2.0 5 votes vote down vote up
@Override
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
  if (value.type().tyKind() == TyKind.ERROR_TY) {
    // represent unresolvable class literals as the string value "<error>" for compatibility
    // with javac: https://bugs.openjdk.java.net/browse/JDK-8229535
    return v.visitString("<error>", p);
  } else {
    return v.visitType(getValue(), p);
  }
}
 
Example #13
Source File: Attribute.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
    return v.visitAnnotation(this, p);
}
 
Example #14
Source File: Attribute.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
    return v.visitType(classType, p);
}
 
Example #15
Source File: Const.java    From turbine with Apache License 2.0 4 votes vote down vote up
@Override
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
  return v.visitInt(value, p);
}
 
Example #16
Source File: ComponentProcessor.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
protected ComponentInfo(Element element) {
  super(element.getSimpleName().toString(),  // Short name
        elementUtils.getDocComment(element),
        elementUtils.getDocComment(element),
        "Component", false, elementUtils.isDeprecated(element));
  type = element.asType().toString();
  displayName = getDisplayNameForComponentType(name);
  permissions = Sets.newHashSet();
  conditionalPermissions = Maps.newTreeMap();
  conditionalBroadcastReceivers = Maps.newTreeMap();
  libraries = Sets.newHashSet();
  nativeLibraries = Sets.newHashSet();
  assets = Sets.newHashSet();
  activities = Sets.newHashSet();
  broadcastReceivers = Sets.newHashSet();
  classNameAndActionsBR = Sets.newHashSet();
  designerProperties = Maps.newTreeMap();
  properties = Maps.newTreeMap();
  methods = Maps.newTreeMap();
  events = Maps.newTreeMap();
  abstractClass = element.getModifiers().contains(Modifier.ABSTRACT);
  external = false;
  versionName = null;
  dateBuilt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(new Date());
  for (AnnotationMirror am : element.getAnnotationMirrors()) {
    DeclaredType dt = am.getAnnotationType();
    String annotationName = am.getAnnotationType().toString();
    if (annotationName.equals(SimpleObject.class.getName())) {
      simpleObject = true;
      SimpleObject simpleObjectAnnotation = element.getAnnotation(SimpleObject.class);
      external = simpleObjectAnnotation.external();
    }
    if (annotationName.equals(DesignerComponent.class.getName())) {
      designerComponent = true;
      DesignerComponent designerComponentAnnotation =
          element.getAnnotation(DesignerComponent.class);
      Map values = elementUtils.getElementValuesWithDefaults(am);
      for (Map.Entry entry : (Set<Map.Entry>) values.entrySet()) {
        if (((ExecutableElement) entry.getKey()).getSimpleName().contentEquals("dateBuilt")) {
          entry.setValue(new AnnotationValue() {
            @Override
            public Object getValue() {
              return dateBuilt;
            }

            @Override
            public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
              return v.visit(this, p);
            }

            @Override
            public String toString() {
              return "\"" + dateBuilt + "\"";
            }
          });
        }
      }

      // Override javadoc description with explicit description
      // if provided.
      String explicitDescription = designerComponentAnnotation.description();
      if (!explicitDescription.isEmpty()) {
        setDescription(explicitDescription);
      }

      // Set helpDescription to the designerHelpDescription field if
      // provided; otherwise, use description
      helpDescription = designerComponentAnnotation.designerHelpDescription();
      if (helpDescription.isEmpty()) {
        helpDescription = description;
      }
      helpUrl = designerComponentAnnotation.helpUrl();
      if (!helpUrl.startsWith("http:") && !helpUrl.startsWith("https:")) {
        helpUrl = "";  // only accept http: or https: URLs (e.g., no javascript:)
      }

      category = designerComponentAnnotation.category().getName();
      categoryString = designerComponentAnnotation.category().toString();
      version = designerComponentAnnotation.version();
      showOnPalette = designerComponentAnnotation.showOnPalette();
      nonVisible = designerComponentAnnotation.nonVisible();
      iconName = designerComponentAnnotation.iconName();
      androidMinSdk = designerComponentAnnotation.androidMinSdk();
      versionName = designerComponentAnnotation.versionName();
      userVisible = designerComponentAnnotation.showOnPalette();
    }
  }
}
 
Example #17
Source File: Attribute.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
    return v.visitString(toString(), p);
}
 
Example #18
Source File: Attribute.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
    return v.visitEnumConstant(value, p);
}
 
Example #19
Source File: Attribute.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
    return v.visitArray(getValue(), p);
}
 
Example #20
Source File: Attribute.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
    return v.visitAnnotation(this, p);
}
 
Example #21
Source File: Attribute.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
    return v.visitType(classType, p);
}
 
Example #22
Source File: Const.java    From turbine with Apache License 2.0 4 votes vote down vote up
@Override
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
  return v.visitLong(value, p);
}
 
Example #23
Source File: Attribute.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
    throw new UnsupportedOperationException();
}
 
Example #24
Source File: Attribute.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
    throw new UnsupportedOperationException();
}
 
Example #25
Source File: Attribute.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
    return v.visitString(toString(), p);
}
 
Example #26
Source File: Attribute.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
    return v.visitAnnotation(this, p);
}
 
Example #27
Source File: Attribute.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
    return v.visitArray(getValue(), p);
}
 
Example #28
Source File: Attribute.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
    return v.visitAnnotation(this, p);
}
 
Example #29
Source File: TurbineAnnotationMirror.java    From turbine with Apache License 2.0 4 votes vote down vote up
@Override
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
  return v.visitArray(elements.get(), p);
}
 
Example #30
Source File: Const.java    From turbine with Apache License 2.0 4 votes vote down vote up
@Override
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
  return v.visitShort(value, p);
}