/** * Creates a {@link ClassRef} without bounds. */ public ClassRef toUnboundedReference() { return new ClassRefBuilder() .withDefinition(this) .withArguments(new TypeRef[0]) .build(); }
/** * Creates a {@link ClassRef} for the current definition with the specified arguments. * * @param arguments The arguments to be passed to the reference. */ public ClassRef toReference(List<TypeRef> arguments) { List<TypeRef> actualArguments = new ArrayList<TypeRef>(); for (int i = 0; i < parameters.size(); i++) { if (i < arguments.size()) { actualArguments.add(arguments.get(i)); } else { actualArguments.add(new WildcardRef()); } } return new ClassRefBuilder() .withDefinition(this) .withArguments(actualArguments) .withAttributes(getAttributes()) .build(); }
/** * Creates a {@link ClassRef} for the current definition with the specified arguments. * * @param arguments The arguments to be passed to the reference. */ public ClassRef toReference(TypeRef... arguments) { List<TypeRef> actualArguments = new ArrayList<TypeRef>(); for (int i = 0; i < parameters.size(); i++) { if (i < arguments.length) { actualArguments.add(arguments[i]); } else { actualArguments.add(new WildcardRef()); } } return new ClassRefBuilder() .withDefinition(this) .withArguments(actualArguments) .withAttributes(getAttributes()) .build(); }
public TypeRef visitDeclared(DeclaredType t, Integer dimension) { List<TypeRef> arguments = new ArrayList<TypeRef>(); for (TypeMirror typeMirror : t.getTypeArguments()) { TypeRef arg = typeMirror.accept(this, dimension); if (arg != null) { arguments.add(arg); } } TypeDef typeDef = new TypeDefElementVisitor().visit(t.asElement()).build(); return new ClassRefBuilder() .withDefinition(typeDef) .withDimensions(dimension) .withArguments(arguments) .build(); }
/** * Creates a {@link ClassRef} for internal use inside the scope of the type (methods, properties * etc). It uses as arguments the same 'letters' as the parameters definition. */ public ClassRef toInternalReference() { List<TypeRef> arguments = new ArrayList<TypeRef>(); for (TypeParamDef parameter : parameters) { arguments.add(parameter.toReference()); } return new ClassRefBuilder() .withDefinition(this) .withArguments(arguments) .withAttributes(getAttributes()) .build(); }
public TypeRef visitError(ErrorType t, Integer dimension) { return new ClassRefBuilder().withDefinition(new TypeDefElementVisitor().visit(t.asElement()).build()).build(); }
public TypeRef apply(TypeMirror item) { if (item instanceof NoType) { return new VoidRef(); } Element element = CodegenContext.getContext().getTypes().asElement(item); TypeDef known = element != null ? CodegenContext.getContext().getDefinitionRepository().getDefinition(element.toString()) : null; if (known == null && element instanceof TypeElement) { known = TYPEDEF.apply((TypeElement) element); } TypeRef typeRef = item.accept(new TypeRefTypeVisitor(), 0); if (typeRef instanceof ClassRef && known != null) { return new ClassRefBuilder((ClassRef) typeRef).withDefinition(known).build(); } return typeRef; } };
} else { return new ClassRefBuilder() .withDefinition(TYPEDEF.apply(c)) .build();
public ClassRefBuilder(ClassRef instance, Boolean validationEnabled) { this.fluent = this; this.withDefinition(instance.getDefinition()); this.withFullyQualifiedName(instance.getFullyQualifiedName()); this.withDimensions(instance.getDimensions()); this.withArguments(instance.getArguments()); this.withAttributes(instance.getAttributes()); this.validationEnabled = validationEnabled; }
? new ClassRefBuilder().withDefinition(knownDefinition).build() : knownDefinition.toReference(arguments); } else if (classOrInterfaceType.getTypeArgs().isEmpty() && boundName.length() == 1) {