/** * 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(); }
.withProperties(properties) .withExtendsList(extendsList) .withImplementsList(implementsList) .build());
.withPackageName(packageName) .withName(className) .withImplementsList(interfaces) .withExtendsList(superClass) .withProperties(fields)
.withParameters(genericTypes) .withExtendsList(superClassType instanceof ClassRef ? (ClassRef) superClassType : null) .withImplementsList(interfaces) .withOuterType(classElement.getEnclosingElement() instanceof TypeElement ? TYPEDEF.apply((TypeElement) classElement.getEnclosingElement()) : null) .build();
public TypeDef apply(TypeDef item) { TypeDef builder = SHALLOW_BUILDER.apply(item); TypeDef fluent = FLUENT_IMPL.apply(item); List<TypeRef> parameters = new ArrayList<TypeRef>(); for (TypeParamDef param : item.getParameters()) { parameters.add(param.toReference()); } parameters.add(builder.toInternalReference()); return new TypeDefBuilder(item) .withKind(Kind.CLASS) .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC)) .withName(item.getName() + "Builder") .withParameters(item.getParameters()) .withInnerTypes() .withExtendsList(fluent.toReference(parameters)) .withImplementsList(BuilderContextManager.getContext().getVisitableBuilderInterface().toReference(item.toInternalReference(), builder.toInternalReference())) .build(); } };
.withParameters(parameters) .withOuterType(outerInterface) .withImplementsList() .withExtendsList(BuilderContextManager.getContext().getNestedInterface().toReference(N.toReference()), superClassFluent) .build();
public TypeDef apply(TypeDef item) { List<TypeParamDef> parameters = new ArrayList<TypeParamDef>(); for (TypeParamDef generic : item.getParameters()) { parameters.add(generic); } return new TypeDefBuilder(item) .withKind(Kind.CLASS) .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC)) .withName("Editable" + item.getName()) .withParameters(parameters) .withExtendsList(item.toInternalReference()) .withImplementsList(BuilderContextManager.getContext().getEditableInterface().toReference(SHALLOW_BUILDER.apply(item).toInternalReference())) .withInnerTypes() .withProperties() .withMethods() .withConstructors() .build(); } };
public TypeDef apply(TypeDef item) { BuilderContext ctx = BuilderContextManager.getContext(); TypeDef fluent = SHALLOW_FLUENT.apply(item); List<TypeParamDef> parameters = new ArrayList<TypeParamDef>(item.getParameters()); List<TypeRef> superClassParameters = new ArrayList<TypeRef>(); TypeParamDef nextParameter = getNextGeneric(item, parameters); ClassRef builableSuperClassRef = findBuildableSuperClassRef(item); TypeDef buildableSuperClass = findBuildableSuperClass(item); if (builableSuperClassRef != null) { superClassParameters.addAll(builableSuperClassRef.getArguments()); } TypeParamDef parameterFluent = new TypeParamDefBuilder(nextParameter).addToBounds(fluent.toInternalReference()).build(); parameters.add(parameterFluent); superClassParameters.add(parameterFluent.toReference()); TypeDef superClass = buildableSuperClass != null ? SHALLOW_FLUENT.apply(buildableSuperClass) : ctx.getFluentInterface(); return new TypeDefBuilder(item) .withKind(Kind.INTERFACE) .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC)) .withName(item.getName() + "Fluent") .withPackageName(item.getPackageName()) .withParameters(parameters) .withExtendsList(superClass.toReference(superClassParameters)) .withImplementsList() .withInnerTypes() .build(); } };
.withConstructors(constructors) .withMethods(getters) .withImplementsList(implementsList) .withExtendsList(extendsList) .addToAttributes(item.getAttributes())
public TypeDef apply(TypeDef item) { BuilderContext ctx = BuilderContextManager.getContext(); TypeDef fluent = SHALLOW_FLUENT.apply(item); List<TypeParamDef> parameters = new ArrayList<TypeParamDef>(item.getParameters()); List<TypeRef> superClassParameters = new ArrayList<TypeRef>(); TypeParamDef nextParameter = getNextGeneric(item, parameters); ClassRef builableSuperClassRef = findBuildableSuperClassRef(item); if (builableSuperClassRef != null) { superClassParameters.addAll(builableSuperClassRef.getArguments()); } TypeParamDef parameterFluent = new TypeParamDefBuilder(nextParameter).addToBounds(fluent.toInternalReference()).build(); parameters.add(parameterFluent); superClassParameters.add(parameterFluent.toReference()); TypeDef buildableSuperClass = findBuildableSuperClass(item); TypeDef superClass = buildableSuperClass != null ? FLUENT_IMPL.apply(buildableSuperClass) : ctx.getBaseFluentClass(); return new TypeDefBuilder(item) .withKind(Kind.CLASS) .withModifiers(TypeUtils.modifiersToInt(Modifier.PUBLIC)) .withName(item.getName() + "FluentImpl") .withPackageName(item.getPackageName()) .withParameters(parameters) .withExtendsList(superClass.toReference(superClassParameters)) .withImplementsList(SHALLOW_FLUENT.apply(item).toInternalReference()) .withInnerTypes() .build(); }
.withParameters(parameters) .withExtendsList(superClassFluent) .withImplementsList(nestedInterfaceRef, BuilderContextManager.getContext().getNestedInterface().toReference(N.toReference())) .build();
.withParameters(parameters) .withExtendsList(extendsList) .withImplementsList(implementsList) .withProperties(properties) .withMethods(methods)
public TypeDefBuilder(TypeDef instance,Boolean validationEnabled){ this.fluent = this; this.withKind(instance.getKind()); this.withPackageName(instance.getPackageName()); this.withName(instance.getName()); this.withComments(instance.getComments()); this.withAnnotations(instance.getAnnotations()); this.withExtendsList(instance.getExtendsList()); this.withImplementsList(instance.getImplementsList()); this.withParameters(instance.getParameters()); this.withProperties(instance.getProperties()); this.withConstructors(instance.getConstructors()); this.withMethods(instance.getMethods()); this.withOuterType(instance.getOuterType()); this.withInnerTypes(instance.getInnerTypes()); this.withModifiers(instance.getModifiers()); this.withAttributes(instance.getAttributes()); this.validationEnabled = validationEnabled; }
.withImplementsList(inlineTypeRef) .withProperties() .withMethods()