/** * This method has been deprecated, please use method buildOuterType instead. * @return The buildable object. */ @Deprecated public TypeDef getOuterType(){ return this.outerType!=null?this.outerType.build():null; }
public TypeDef buildMatchingInnerType(Predicate<TypeDefBuilder> predicate){ for (TypeDefBuilder item: innerTypes) { if(predicate.apply(item)){return item.build();} } return null; }
/** * Removes parameters from a TypeDef. * @param base The base type. * @return The unwraped TypeDef. */ public static TypeDef unwrapGeneric(TypeDef base) { return new TypeDefBuilder(base).withParameters().build(); }
/** * Sets one {@link io.sundr.codegen.model.TypeDef} as a super class of an other. * * @param base The base type. * @param superClass The super type. * @return The updated type definition. */ public static TypeDef typeExtends(TypeDef base, ClassRef superClass) { return new TypeDefBuilder(base) .withExtendsList(superClass) .build(); }
/** * Sets one {@link io.sundr.codegen.model.TypeDef} as a generic of an other. * * @param base The base type. * @param parameters The parameter types. * @return The generic type. */ public static TypeDef typeGenericOf(TypeDef base, TypeParamDef... parameters) { return new TypeDefBuilder(base) .withParameters(parameters) .build(); }
/** * Sets one {@link io.sundr.codegen.model.TypeDef} as an interface of an other. * * @param base The base type. * @param superClass The super type. * @return The updated type definition. */ public static TypeDef typeImplements(TypeDef base, ClassRef... superClass) { return new TypeDefBuilder(base) .withImplementsList(superClass) .build(); }
public TypeDef apply(Model model) { return new TypeDefBuilder() .withKind(Kind.CLASS) .build(); } };
public TypeDef apply(Model model) { return new TypeDefBuilder() .withKind(Kind.CLASS) .build(); } };
public TypeDef apply(TypeDef type) { return new TypeDefBuilder(type).accept(UNWRAP_CLASSREF_VISITOR).build(); } };
public Set<TypeDef> apply(Set<TypeDef> source) { Set<TypeDef> result = new LinkedHashSet<TypeDef>(source); Set<TypeParamDef> typeParameters = findParameters(source); for (TypeParamDef type : typeParameters) { Set<TypeDef> intermediate = new LinkedHashSet<TypeDef>(); for (TypeDef clazz : result) { intermediate.add(new TypeDefBuilder(clazz).accept(new TypeParamDefReplace(type, Generics.MAP.apply(type.toReference()))).build()); } result = new LinkedHashSet<TypeDef>(intermediate); } return result; } };
public void selectAnnotated(RoundEnvironment env, Types types, AnnotationSelector selector, Map<String, TypeDef> definitions) { for (Object o : env.getElementsAnnotatedWith((TypeElement) types.asElement(annotationMirror(selector)))) { if (o instanceof TypeElement) { TypeDef typeDef = new TypeDefBuilder(ElementTo.TYPEDEF.apply(ModelUtils.getClassElement((Element) o))) .build(); definitions.put(typeDef.getFullyQualifiedName(), typeDef); } } }
public TypeDef register(TypeDef definition, AttributeKey<Boolean>... flags) { TypeDefBuilder builder = new TypeDefBuilder(definition); for (AttributeKey<Boolean> flag : flags) { builder.addToAttributes(flag, true); } return register(builder.build()); }
private static List<TypeDef> setOuterType(List<TypeDef> types, TypeDef outer) { List<TypeDef> updated = new ArrayList<TypeDef>(); for (TypeDef typeDef : types) { if (outer.equals(typeDef.getOuterType())) { updated.add(typeDef); } else { updated.add(new TypeDefBuilder(typeDef).withOuterType(outer).withPackageName(outer.getPackageName()).build()); } } return updated; }
public ClassRef(TypeDef definition, String fullyQualifiedName, int dimensions, List<TypeRef> arguments, Map<AttributeKey, Object> attributes) { super(attributes); this.definition = definition != null ? definition : new TypeDefBuilder().build(); this.dimensions = dimensions; this.arguments = arguments; this.fullyQualifiedName = fullyQualifiedName != null ? fullyQualifiedName : (definition != null ? definition.getFullyQualifiedName() : null); if (definition != null) { DefinitionRepository.getRepository().registerIfAbsent(definition); } }
public TypeDef register(TypeDef definition, String... flags) { TypeDefBuilder builder = new TypeDefBuilder(definition); for (String flag : flags) { builder.addToAttributes(new AttributeKey<Boolean>(flag, Boolean.class), true); } return register(builder.build()); }
public TypeDef apply(ClassOrInterfaceType item) { List<TypeParamDef> parameters = new ArrayList<TypeParamDef>(); for (Type type : item.getTypeArgs()) { new TypeParamDefBuilder() .build(); } return new TypeDefBuilder() .withName(item.getName()) .withParameters(parameters) .build(); } }
private static final Set<TypeParamDef> extractParameters(TypeDef typeDef) { final Set<TypeParamDef> result = new LinkedHashSet<TypeParamDef>(); final Set<TypeParamRef> refs = new LinkedHashSet<TypeParamRef>(); TypeDef ignored = new TypeDefBuilder(typeDef).accept(new TypeParamDefColletor(result)).accept(new TypeParamRefColletor(refs)).build(); for (TypeParamRef typeParamRef : refs) { result.add(new TypeParamDefBuilder().withName(typeParamRef.getName()).withAttributes(typeParamRef.getAttributes()).build()); } return result; }
public TypeDef apply(TypeDef item) { List<TypeParamDef> parameters = new ArrayList<TypeParamDef>(item.getParameters()); parameters.add(getNextGeneric(item)); return new TypeDefBuilder(item) .withKind(Kind.INTERFACE) .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC)) .withName(item.getName() + "Fluent") .withParameters(parameters) .withInnerTypes() .build(); } };
public TypeDef apply(TypeDef item) { return new TypeDefBuilder(item) .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC)) .withName(item.getName() + "Builder") .withInnerTypes() .build(); } };
public TypeDef getInlineableInterface(Inline inline) { return new TypeDefBuilder(inlineableBase) .withKind(Kind.INTERFACE) .withPackageName(builderPackage) .withName(inline.prefix() + (!inline.name().isEmpty() ? inline.name() : INLINEABLE.getName()) + inline.suffix()) .withParameters(INLINEABLE.getParameters()) .addNewMethod() .withReturnType(TypeUtils.newTypeParamRef("T")) .withName(inline.value()) .and() .build(); }