use of javax.lang.model.element.AnnotationMirror in project realm-java by realm.
the class ModuleMetaData method getClassMetaDataFromModule.
// Detour needed to access the class elements in the array
// See http://blog.retep.org/2009/02/13/getting-class-values-from-annotations-in-an-annotationprocessor/
@SuppressWarnings("unchecked")
private Set<String> getClassMetaDataFromModule(Element classElement) {
AnnotationMirror annotationMirror = getAnnotationMirror(classElement);
AnnotationValue annotationValue = getAnnotationValue(annotationMirror);
Set<String> classes = new HashSet<String>();
List<? extends AnnotationValue> moduleClasses = (List<? extends AnnotationValue>) annotationValue.getValue();
for (AnnotationValue classMirror : moduleClasses) {
String fullyQualifiedClassName = classMirror.getValue().toString();
classes.add(fullyQualifiedClassName);
}
return classes;
}
use of javax.lang.model.element.AnnotationMirror in project realm-java by realm.
the class ModuleMetaData method hasCustomClassList.
// Work-around for asking for a Class primitive array which would otherwise throw a TypeMirrorException
// https://community.oracle.com/thread/1184190
@SuppressWarnings("unchecked")
private boolean hasCustomClassList(Element classElement) {
AnnotationMirror annotationMirror = getAnnotationMirror(classElement);
AnnotationValue annotationValue = getAnnotationValue(annotationMirror);
if (annotationValue == null) {
return false;
} else {
List<? extends AnnotationValue> moduleClasses = (List<? extends AnnotationValue>) annotationValue.getValue();
return moduleClasses.size() > 0;
}
}
use of javax.lang.model.element.AnnotationMirror in project robolectric by robolectric.
the class Validator method message.
protected void message(Kind severity, String msg, AnnotationValue av) {
final AnnotationMirror am = getCurrentAnnotation();
messager.printMessage(severity, msg, currentElement, am, av);
}
use of javax.lang.model.element.AnnotationMirror in project spring-boot by spring-projects.
the class ConfigurationMetadataAnnotationProcessor method processNestedType.
private void processNestedType(String prefix, TypeElement element, ExecutableElement source, String name, ExecutableElement getter, VariableElement field, TypeMirror returnType) {
Element returnElement = this.processingEnv.getTypeUtils().asElement(returnType);
boolean isNested = isNested(returnElement, field, element);
AnnotationMirror annotation = getAnnotation(getter, configurationPropertiesAnnotation());
if (returnElement != null && returnElement instanceof TypeElement && annotation == null && isNested) {
String nestedPrefix = ConfigurationMetadata.nestedPrefix(prefix, name);
this.metadataCollector.add(ItemMetadata.newGroup(nestedPrefix, this.typeUtils.getQualifiedName(returnElement), this.typeUtils.getQualifiedName(element), (getter == null ? null : getter.toString())));
processTypeElement(nestedPrefix, (TypeElement) returnElement, source);
}
}
use of javax.lang.model.element.AnnotationMirror in project spring-boot by spring-projects.
the class ConfigurationMetadataAnnotationProcessor method getItemDeprecation.
private ItemDeprecation getItemDeprecation(ExecutableElement getter) {
AnnotationMirror annotation = getAnnotation(getter, deprecatedConfigurationPropertyAnnotation());
String reason = null;
String replacement = null;
if (annotation != null) {
Map<String, Object> elementValues = getAnnotationElementValues(annotation);
reason = (String) elementValues.get("reason");
replacement = (String) elementValues.get("replacement");
}
return new ItemDeprecation(("".equals(reason) ? null : reason), ("".equals(replacement) ? null : replacement));
}
Aggregations