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 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(); } };
.withExtendsList(superClassType instanceof ClassRef ? (ClassRef) superClassType : null) .withImplementsList(interfaces) .withOuterType(classElement.getEnclosingElement() instanceof TypeElement ? TYPEDEF.apply((TypeElement) classElement.getEnclosingElement()) : null) .build(); for (TypeElement innerElement : ElementFilter.typesIn(classElement.getEnclosedElements())) { TypeDef innerType = TYPEDEF.apply(innerElement); innerType = new TypeDefBuilder(innerType).withOuterType(baseType).build(); DefinitionRepository.getRepository().register(innerType); innerTypes.add(innerType);
public TypeDef apply(Property item) { TypeDef nested = new TypeDefBuilder(SHALLOW_NESTED_TYPE.apply(item)).withOuterType(item.getAttribute(OUTER_INTERFACE)).build(); TypeDef outerInterface = item.getAttribute(OUTER_INTERFACE); .withPackageName(outerInterface.getPackageName()) .withParameters(parameters) .withOuterType(outerInterface) .withImplementsList() .withExtendsList(BuilderContextManager.getContext().getNestedInterface().toReference(N.toReference()), superClassFluent)
.withPackageName(outerClass.getPackageName()) .withName(shallowNestedType.getName() + "Impl") .withOuterType(outerClass) .build();
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; }