Java Code Examples for javax.lang.model.element.AnnotationValue#accept()

The following examples show how to use javax.lang.model.element.AnnotationValue#accept() . 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: MatchProcessor.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@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;
}
 
Example 2
Source File: FindIndexesVisitor.java    From kripton with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitArray(List<? extends AnnotationValue> vals, String p) {
	for (AnnotationValue val : vals) {
		val.accept(this, p);
	}
	return null;
}
 
Example 3
Source File: FindSqlChildSelectVisitor.java    From kripton with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitArray(List<? extends AnnotationValue> vals, String p) {
	if (AnnotationAttributeType.CHILDREN_SELECT.getValue().equals(p)) {
		activate = true;
		for (AnnotationValue val : vals) {
			current = new Triple<>();
			childrenSelects.add(current);
			val.accept(this, p);
		}
		activate = false;
	}
	return null;
}
 
Example 4
Source File: AnnotationSpec.java    From JReFrameworker with MIT License 5 votes vote down vote up
public static AnnotationSpec get(AnnotationMirror annotation) {
  TypeElement element = (TypeElement) annotation.getAnnotationType().asElement();
  AnnotationSpec.Builder builder = AnnotationSpec.builder(ClassName.get(element));
  Visitor visitor = new Visitor(builder);
  for (ExecutableElement executableElement : annotation.getElementValues().keySet()) {
    String name = executableElement.getSimpleName().toString();
    AnnotationValue value = annotation.getElementValues().get(executableElement);
    value.accept(visitor, name);
  }
  return builder.build();
}
 
Example 5
Source File: FindTasksVisitor.java    From kripton with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitArray(List<? extends AnnotationValue> vals, String p) {
	for (AnnotationValue val : vals) {
		val.accept(this, p);
	}
	return null;
}
 
Example 6
Source File: FindXmlNamespaceVisitor.java    From kripton with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitArray(List<? extends AnnotationValue> vals, String p) {
	if (AnnotationAttributeType.NAMESPACES.getValue().equals(p)) {
		activate = true;
		for (AnnotationValue val : vals) {
			current = new Pair<>();
			namespaces.add(current);
			val.accept(this, p);
		}
		activate = false;
	}
	return null;
}
 
Example 7
Source File: ElementUtils.java    From spring-init with Apache License 2.0 4 votes vote down vote up
@Override
public Boolean visit(AnnotationValue av, String name) {
	return av.accept(this, name);
}
 
Example 8
Source File: ElementUtils.java    From spring-init with Apache License 2.0 4 votes vote down vote up
@Override
public Boolean visit(AnnotationValue av) {
	return av.accept(this, null);
}
 
Example 9
Source File: ElementUtils.java    From spring-init with Apache License 2.0 4 votes vote down vote up
@Override
public Boolean visit(AnnotationValue av) {
	return av.accept(this, null);
}
 
Example 10
Source File: AnnotationSpec.java    From JReFrameworker with MIT License 4 votes vote down vote up
@Override public Builder visitArray(List<? extends AnnotationValue> values, String name) {
  for (AnnotationValue value : values) {
    value.accept(this, name);
  }
  return builder;
}
 
Example 11
Source File: ElementUtils.java    From spring-init with Apache License 2.0 4 votes vote down vote up
@Override
public Boolean visit(AnnotationValue av) {
	return av.accept(this, null);
}
 
Example 12
Source File: ElementUtils.java    From spring-init with Apache License 2.0 4 votes vote down vote up
@Override
public Boolean visit(AnnotationValue av, List<AnnotationMirror> collected) {
	return av.accept(this, collected);
}
 
Example 13
Source File: Utils.java    From paperparcel with Apache License 2.0 4 votes vote down vote up
static OptionsDescriptor getModuleOptions(AnnotationMirror processorConfig) {
  AnnotationValue optionsAnnotationValue =
      AnnotationMirrors.getAnnotationValue(processorConfig, "options");
  AnnotationMirror optionsMirror = optionsAnnotationValue.accept(TO_ANNOTATION, null);
  return parseOptions(optionsMirror);
}
 
Example 14
Source File: AnnotationSpec.java    From JReFrameworker with MIT License 4 votes vote down vote up
@Override public Builder visitArray(List<? extends AnnotationValue> values, String name) {
  for (AnnotationValue value : values) {
    value.accept(this, name);
  }
  return builder;
}
 
Example 15
Source File: Utils.java    From paperparcel with Apache License 2.0 4 votes vote down vote up
private static ImmutableList<String> getExposeAnnotations(AnnotationMirror mirror) {
  AnnotationValue exposeAnnotationNames =
      AnnotationMirrors.getAnnotationValue(mirror, "exposeAnnotations");
  return exposeAnnotationNames.accept(TYPE_NAME_ARRAY_VISITOR, null);
}
 
Example 16
Source File: Utils.java    From paperparcel with Apache License 2.0 4 votes vote down vote up
private static boolean getExcludeNonExposedFields(AnnotationMirror mirror) {
  AnnotationValue excludeNonExposedFields =
      AnnotationMirrors.getAnnotationValue(mirror, "excludeNonExposedFields");
  return excludeNonExposedFields.accept(TO_BOOLEAN, null);
}
 
Example 17
Source File: Utils.java    From paperparcel with Apache License 2.0 4 votes vote down vote up
private static ImmutableList<String> getReflectAnnotations(AnnotationMirror mirror) {
  AnnotationValue exposeAnnotationNames =
      AnnotationMirrors.getAnnotationValue(mirror, "reflectAnnotations");
  return exposeAnnotationNames.accept(TYPE_NAME_ARRAY_VISITOR, null);
}
 
Example 18
Source File: Utils.java    From paperparcel with Apache License 2.0 4 votes vote down vote up
private static boolean getAllowSerializable(AnnotationMirror mirror) {
  AnnotationValue allowSerializable =
      AnnotationMirrors.getAnnotationValue(mirror, "allowSerializable");
  return allowSerializable.accept(TO_BOOLEAN, null);
}
 
Example 19
Source File: ElementUtils.java    From spring-init with Apache License 2.0 4 votes vote down vote up
@Override
public Boolean visit(AnnotationValue av) {
	return av.accept(this, null);
}
 
Example 20
Source File: ElementUtils.java    From spring-init with Apache License 2.0 4 votes vote down vote up
@Override
public Boolean visit(AnnotationValue av, List<TypeElement> collected) {
	return av.accept(this, collected);
}