use of io.sundr.adapter.apt.visitors.TypeRefTypeVisitor in project sundrio by sundrio.
the class AnnotationMirrorToAnnotationRef method apply.
@Override
public AnnotationRef apply(AnnotationMirror item) {
TypeRef annotationType = item.getAnnotationType().accept(new TypeRefTypeVisitor(context), 0);
Map<String, Object> parameters = new HashMap<String, Object>();
if (annotationType instanceof ClassRef) {
for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : item.getElementValues().entrySet()) {
checkEntry(entry);
String key = entry.getKey().toString().replace(EMPTY_PARENTHESIS, EMPTY);
Object value = mapAnnotationValue(entry.getValue().getValue());
parameters.put(key, value);
}
return new AnnotationRefBuilder().withClassRef((ClassRef) annotationType).withParameters(parameters).build();
}
throw new IllegalStateException("Annotation type: [" + annotationType + "] is not a class reference.");
}
use of io.sundr.adapter.apt.visitors.TypeRefTypeVisitor in project sundrio by sundrio.
the class TypeMirrorToTypeRef method apply.
@Override
public TypeRef apply(TypeMirror item) {
if (item instanceof NoType) {
return new VoidRef();
}
if (item == null) {
throw new IllegalArgumentException("TypeMirror cannot be null.");
}
Element element = AptContext.getContext().getTypes().asElement(item);
TypeRef typeRef = item.accept(new TypeRefTypeVisitor(context), 0);
if (typeRef instanceof ClassRef && element instanceof TypeElement) {
TypeElement typeElement = (TypeElement) element;
String fqcn = typeElement.toString();
context.getReferences().add((TypeElement) element);
return new ClassRefBuilder((ClassRef) typeRef).withNewFullyQualifiedName(fqcn).build();
}
return typeRef;
}
Aggregations