use of io.sundr.model.VoidRef 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;
}
use of io.sundr.model.VoidRef in project sundrio by sundrio.
the class TypeToTypeRef method apply.
@Override
public TypeRef apply(Type type) {
if (type instanceof VoidType) {
return new VoidRef();
} else if (type instanceof WildcardType) {
return new WildcardRef();
} else if (type instanceof ReferenceType) {
ReferenceType referenceType = (ReferenceType) type;
int dimensions = referenceType.getArrayCount();
TypeRef typeRef = apply(referenceType.getType());
if (dimensions == 0) {
return typeRef;
} else if (typeRef instanceof ClassRef) {
return new ClassRefBuilder((ClassRef) typeRef).withDimensions(dimensions).build();
} else if (typeRef instanceof PrimitiveRef) {
return new PrimitiveRefBuilder((PrimitiveRef) typeRef).withDimensions(dimensions).build();
} else if (typeRef instanceof TypeParamRef) {
return new TypeParamRefBuilder((TypeParamRef) typeRef).withDimensions(dimensions).build();
}
} else if (type instanceof PrimitiveType) {
PrimitiveType primitiveType = (PrimitiveType) type;
return new PrimitiveRefBuilder().withName(primitiveType.getType().name()).build();
} else if (type instanceof ClassOrInterfaceType) {
return classOrInterfaceToTypeRef.apply((ClassOrInterfaceType) type);
}
throw new IllegalArgumentException("Can't handle type:[" + type + "].");
}
Aggregations