/** * 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(); }
.withMethods(methods) .withProperties(properties) .withExtendsList(extendsList) .withImplementsList(implementsList) .build());
.withName(className) .withImplementsList(interfaces) .withExtendsList(superClass) .withProperties(fields) .withMethods(methods)
public TypeDef apply(TypeElement classElement) { List<ClassRef> extendsList = new ArrayList<ClassRef>(); //Check SuperClass Kind kind = Kind.CLASS; if (classElement.getKind() == ElementKind.INTERFACE) { kind = Kind.INTERFACE; } else if (classElement.getKind() == ElementKind.CLASS) { kind = Kind.CLASS; extendsList.add(TypeDef.OBJECT_REF); } else if (classElement.getKind() == ElementKind.ANNOTATION_TYPE) { kind = Kind.ANNOTATION; } Set<Method> allMethods = new LinkedHashSet<Method>(); for (ExecutableElement method : ElementFilter.methodsIn(classElement.getEnclosedElements())) { } return new TypeDefBuilder() .withKind(kind) .withModifiers(TypeUtils.modifiersToInt(classElement.getModifiers())) .withPackageName(getPackageName(classElement)) .withName(getClassName(classElement)) .withExtendsList(extendsList) .addAllToMethods(allMethods) .withOuterType(classElement.getEnclosingElement() instanceof TypeElement ? SHALLOW_TYPEDEF.apply((TypeElement) classElement.getEnclosingElement()) : null) .build(); } };
.withName(className) .withPackageName(packageName) .withExtendsList(interfaces) .withParameters(parameters.toArray(new TypeParamDef[parameters.size()])) .addToAttributes(ORIGINAL_RETURN_TYPE, TRANSPARENT_REF)
.withName(className) .withPackageName(packageName) .withExtendsList(interfaces) .withParameters(parameters.toArray(new TypeParamDef[parameters.size()])) .addToAttributes(ORIGINAL_RETURN_TYPE, TRANSPARENT_REF)
public TypeDef apply(Node<TypeDef> item) { List<ClassRef> interfaces = new ArrayList<ClassRef>(); for (Node<TypeDef> child : item.getTransitions()) { ClassRef transitionInterface = TO_TRANSITION.apply(child); interfaces.add(transitionInterface); CodegenContext.getContext().getDefinitionRepository().register(child.getItem(), IS_GENERATED); } TypeDef rootType = new TypeDefBuilder(item.getItem()) .withExtendsList(interfaces) .withParameters() .withMethods() .build(); return new TypeDefBuilder(Generics.UNWRAP.apply(rootType)) .withMethods(new ArrayList<Method>()) .build(); } };
.withName(getClassName(classElement)) .withParameters(genericTypes) .withExtendsList(superClassType instanceof ClassRef ? (ClassRef) superClassType : null) .withImplementsList(interfaces) .withOuterType(classElement.getEnclosingElement() instanceof TypeElement ? TYPEDEF.apply((TypeElement) classElement.getEnclosingElement()) : null)
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(); } };
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(); } };
.withOuterType(outerInterface) .withImplementsList() .withExtendsList(BuilderContextManager.getContext().getNestedInterface().toReference(N.toReference()), superClassFluent) .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); 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(); }
.withMethods(getters) .withImplementsList(implementsList) .withExtendsList(extendsList) .addToAttributes(item.getAttributes()) .build();
.withPackageName(scopeInterface.getDefinition().getPackageName()) .withName(scopeInterface.getDefinition().getName() + SCOPE_SUFFIX) .withExtendsList(scopeInterface) .withMethods() .addToAttributes(CARDINALITY_MULTIPLE, multiple)
.withKind(Kind.CLASS) .withParameters(parameters) .withExtendsList(superClassFluent) .withImplementsList(nestedInterfaceRef, BuilderContextManager.getContext().getNestedInterface().toReference(N.toReference())) .build();
.withModifiers(type.getModifiers()) .withParameters(parameters) .withExtendsList(extendsList) .withImplementsList(implementsList) .withProperties(properties)
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; }