use of javax.lang.model.element.AnnotationValue in project DeepLinkDispatch by airbnb.
the class DeepLinkProcessor method enumerateCustomDeepLinks.
private static List<String> enumerateCustomDeepLinks(Element element, Map<Element, String[]> prefixesMap) {
Set<? extends AnnotationMirror> annotationMirrors = AnnotationMirrors.getAnnotatedAnnotations(element, DEEP_LINK_SPEC_CLASS);
final List<String> deepLinks = new ArrayList<>();
for (AnnotationMirror customAnnotation : annotationMirrors) {
List<? extends AnnotationValue> suffixes = asAnnotationValues(AnnotationMirrors.getAnnotationValue(customAnnotation, "value"));
String[] prefixes = prefixesMap.get(customAnnotation.getAnnotationType().asElement());
for (String prefix : prefixes) {
for (AnnotationValue suffix : suffixes) {
deepLinks.add(prefix + suffix.getValue());
}
}
}
return deepLinks;
}
use of javax.lang.model.element.AnnotationValue in project neo4j by neo4j.
the class ServiceProcessor method process.
@SuppressWarnings("unchecked")
@Override
protected void process(TypeElement annotationType, Element annotated, AnnotationMirror annotation, Map<? extends ExecutableElement, ? extends AnnotationValue> values) throws IOException {
for (AnnotationValue o : (List<? extends AnnotationValue>) values.values().iterator().next().getValue()) {
TypeMirror service = (TypeMirror) o.getValue();
addTo(((TypeElement) annotated).getQualifiedName().toString(), "META-INF", "services", service.toString());
}
}
use of javax.lang.model.element.AnnotationValue in project bazel by bazelbuild.
the class AnnotationUtils method getElementValueEnumArray.
/**
* Get the attribute with the name {@code name} of the annotation
* {@code anno}, or the default value if no attribute is present explicitly,
* where the attribute has an array type and the elements are {@code Enum}s.
* One element of the result is expected to have type {@code expectedType}.
*/
public static <T extends Enum<T>> List<T> getElementValueEnumArray(AnnotationMirror anno, CharSequence name, Class<T> t, boolean useDefaults) {
@SuppressWarnings("unchecked") List<AnnotationValue> la = getElementValue(anno, name, List.class, useDefaults);
List<T> result = new ArrayList<T>(la.size());
for (AnnotationValue a : la) {
T value = Enum.valueOf(t, a.getValue().toString());
result.add(value);
}
return result;
}
use of javax.lang.model.element.AnnotationValue in project bazel by bazelbuild.
the class AnnotationUtils method getElementValueArray.
/**
* Get the attribute with the name {@code name} of the annotation
* {@code anno}, where the attribute has an array type. One element of the
* result is expected to have type {@code expectedType}.
*
* Parameter useDefaults is used to determine whether default values
* should be used for annotation values. Finding defaults requires
* more computation, so should be false when no defaulting is needed.
*
* @param anno the annotation to disassemble
* @param name the name of the attribute to access
* @param expectedType the expected type used to cast the return type
* @param useDefaults whether to apply default values to the attribute.
* @return the value of the attribute with the given name
*/
public static <T> List<T> getElementValueArray(AnnotationMirror anno, CharSequence name, Class<T> expectedType, boolean useDefaults) {
@SuppressWarnings("unchecked") List<AnnotationValue> la = getElementValue(anno, name, List.class, useDefaults);
List<T> result = new ArrayList<T>(la.size());
for (AnnotationValue a : la) {
result.add(expectedType.cast(a.getValue()));
}
return result;
}
use of javax.lang.model.element.AnnotationValue in project tiger by google.
the class Utils method findAllModulesRecursively.
@SuppressWarnings("unchecked")
public static Set<TypeElement> findAllModulesRecursively(TypeElement inModule) {
Set<TypeElement> result = new HashSet<>();
result.add(inModule);
for (AnnotationMirror annotationMirror : inModule.getAnnotationMirrors()) {
for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : annotationMirror.getElementValues().entrySet()) {
ExecutableElement key = entry.getKey();
/** Checks for {@link Module.includes}. */
if (key.getSimpleName().contentEquals("includes")) {
for (AnnotationValue annotationValue : (List<AnnotationValue>) entry.getValue().getValue()) {
TypeElement childModule = (TypeElement) ((DeclaredType) annotationValue.getValue()).asElement();
result.addAll(findAllModulesRecursively(childModule));
}
}
}
}
return result;
}
Aggregations