Java Code Examples for com.google.auto.common.AnnotationMirrors#getAnnotationValue()

The following examples show how to use com.google.auto.common.AnnotationMirrors#getAnnotationValue() . 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: AutoOneOfProcessor.java    From auto with Apache License 2.0 5 votes vote down vote up
private DeclaredType mirrorForKindType(TypeElement autoOneOfType) {
  Optional<AnnotationMirror> oneOfAnnotation =
      getAnnotationMirror(autoOneOfType, AUTO_ONE_OF_NAME);
  if (!oneOfAnnotation.isPresent()) {
    // This shouldn't happen unless the compilation environment is buggy,
    // but it has happened in the past and can crash the compiler.
    errorReporter()
        .abortWithError(
            autoOneOfType,
            "annotation processor for @AutoOneOf was invoked with a type"
                + " that does not have that annotation; this is probably a compiler bug");
  }
  AnnotationValue kindValue =
      AnnotationMirrors.getAnnotationValue(oneOfAnnotation.get(), "value");
  Object value = kindValue.getValue();
  if (value instanceof TypeMirror) {
    TypeMirror kindType = (TypeMirror) value;
    switch (kindType.getKind()) {
      case DECLARED:
        return MoreTypes.asDeclared(kindType);
      case ERROR:
        throw new MissingTypeException(MoreTypes.asError(kindType));
      default:
        break;
    }
  }
  throw new MissingTypeException(null);
}
 
Example 2
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 3
Source File: Utils.java    From paperparcel with Apache License 2.0 4 votes vote down vote up
private static ImmutableList<Set<Modifier>> getExcludeModifiers(AnnotationMirror mirror) {
  AnnotationValue excludeFieldsWithModifiers =
      AnnotationMirrors.getAnnotationValue(mirror, "excludeModifiers");
  return convertModifiers(excludeFieldsWithModifiers.accept(INT_ARRAY_VISITOR, null));
}
 
Example 4
Source File: Utils.java    From paperparcel with Apache License 2.0 4 votes vote down vote up
private static ImmutableList<String> getExcludeAnnotations(AnnotationMirror mirror) {
  AnnotationValue excludeAnnotationNames =
      AnnotationMirrors.getAnnotationValue(mirror, "excludeAnnotations");
  return excludeAnnotationNames.accept(TYPE_NAME_ARRAY_VISITOR, null);
}
 
Example 5
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 6
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 7
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 8
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);
}