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 requery by requery.
the class AndroidObservableExtension method addToSetter.
@Override
public void addToSetter(AttributeDescriptor member, MethodSpec.Builder builder) {
if (!observable || !isBindable(member)) {
return;
}
Elements elements = processingEnvironment.getElementUtils();
// data binding compiler will create a useful set of classes in /data-binding-info
String bindingInfo = BINDING_PACKAGE + ".layouts.DataBindingInfo";
TypeElement dataBindingType = elements.getTypeElement(bindingInfo);
ClassName BRclass = null;
if (dataBindingType != null) {
Optional<String> modulePackage = Mirrors.findAnnotationMirror(dataBindingType, BINDING_PACKAGE + ".BindingBuildInfo").map(mirror -> Mirrors.findAnnotationValue(mirror, "modulePackage")).filter(Optional::isPresent).map(Optional::get).map(AnnotationValue::toString);
if (modulePackage.isPresent()) {
// not actually checking the BR class exists since it maybe generated later
BRclass = ClassName.get(modulePackage.get().replaceAll("\"", ""), "BR");
}
}
if (BRclass == null) {
PackageElement packageElement = elements.getPackageOf(entity.element());
String packageName = packageElement.getQualifiedName().toString();
BRclass = ClassName.get(packageName, "BR");
}
// matching the way the BR property names are generated
// https://code.google.com/p/android/issues/detail?id=199436
String propertyName = member.setterName().replaceFirst("set", "");
/*
if (Names.isAllUpper(propertyName)) {
propertyName = propertyName.toLowerCase();
} else {
propertyName = Names.lowerCaseFirst(propertyName);
}*/
propertyName = Names.lowerCaseFirst(propertyName);
builder.addStatement("notifyPropertyChanged($L.$L)", BRclass, propertyName);
}
use of javax.lang.model.element.AnnotationValue in project stitch by bambootang.
the class StithBinderProcess method getAutoLink.
public Object getAutoLink(TypeElement foo) {
AnnotationMirror am = getAnnotationMirror(foo, Exported.class);
if (am == null) {
return null;
}
AnnotationValue av = getAnnotationValue(am, "value");
if (av == null) {
return null;
} else {
return av.getValue();
}
}
use of javax.lang.model.element.AnnotationValue in project androidannotations by androidannotations.
the class AnnotationHelper method extractAnnotationClassArrayParameter.
public List<DeclaredType> extractAnnotationClassArrayParameter(Element element, String annotationName, String methodName) {
AnnotationMirror annotationMirror = findAnnotationMirror(element, annotationName);
Map<? extends ExecutableElement, ? extends AnnotationValue> elementValues = annotationMirror.getElementValues();
for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : elementValues.entrySet()) {
/*
* "methodName" is unset when the default value is used
*/
if (methodName.equals(entry.getKey().getSimpleName().toString())) {
AnnotationValue annotationValue = entry.getValue();
@SuppressWarnings("unchecked") List<AnnotationValue> annotationClassArray = (List<AnnotationValue>) annotationValue.getValue();
List<DeclaredType> result = new ArrayList<>(annotationClassArray.size());
for (AnnotationValue annotationClassValue : annotationClassArray) {
result.add((DeclaredType) annotationClassValue.getValue());
}
return result;
}
}
return null;
}
Aggregations