@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ClassRef classRef = (ClassRef) o; if (dimensions != classRef.dimensions) return false; if (definition != null ? !definition.equals(classRef.definition) : classRef.definition != null) return false; return arguments != null ? arguments.equals(classRef.arguments) : classRef.arguments == null; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; TypeDef typeDef = (TypeDef) o; if (packageName != null ? !packageName.equals(typeDef.packageName) : typeDef.packageName != null) return false; if (outerType != null ? !outerType.equals(typeDef.outerType) : typeDef.outerType != null) return false; return name != null ? name.equals(typeDef.name) : typeDef.name == null; }
public boolean equals(Object o){ if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; ClassRefFluentImpl that = (ClassRefFluentImpl) o; if (definition != null ? !definition.equals(that.definition) :that.definition != null) return false; if (fullyQualifiedName != null ? !fullyQualifiedName.equals(that.fullyQualifiedName) :that.fullyQualifiedName != null) return false; if (dimensions != that.dimensions) return false; if (arguments != null ? !arguments.equals(that.arguments) :that.arguments != null) return false; return true; }
/** * Unrolls the hierararchy of a specified type. * @param typeDef The specified type. * @return A set that contains all the hierarching (including the specified type). */ public static Set<TypeDef> unrollHierarchy(TypeDef typeDef) { if (OBJECT.equals(typeDef)) { return new HashSet<>(); } Set<TypeDef> hierarchy = new HashSet<>(); hierarchy.add(typeDef); hierarchy.addAll(typeDef.getExtendsList().stream().flatMap(s -> unrollHierarchy(s.getDefinition()).stream()).collect(Collectors.toSet())); return hierarchy; }
private static boolean canBeExcluded(TypeDef candidate, Iterable<TypeDef> provided) { Set<TypeDef> allOther = new LinkedHashSet<TypeDef>(); for (TypeDef c : provided) { if (!c.equals(candidate)) { allOther.add(c); } } Set<ClassRef> allProvided = TypeDefUtils.extractInterfacesFromTypes(allOther); for (ClassRef type : TypeDefUtils.extractInterfacesFromType(candidate)) { if (!allProvided.contains(type)) { return false; } } return true; }
public Set<TypeDef> apply(TypeDef item) { if (item.equals(TypeDef.OBJECT)) { return new LinkedHashSet<TypeDef>(); } Set<TypeDef> result = new LinkedHashSet<TypeDef>(); BuilderContext ctx = BuilderContextManager.getContext(); BuildableRepository repository = ctx.getBuildableRepository(); for (TypeDef type : repository.getBuildables()) { if (type.getKind() == Kind.CLASS && !type.isAbstract() && isDescendant(type, item) && !type.equals(item) && !type.hasAttribute(GENERATED)) { result.add(type); } } return result; } });
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 boolean isAssignableFrom(TypeDef o) { if (this == o || this.equals(o)) { return true; } if (packageName == null && "java.lang".equals(o.packageName) && name.equalsIgnoreCase(o.name)) { return true; } if (o.packageName == null && "java.lang".equals(packageName) && name.equalsIgnoreCase(o.name)) { return true; } for (ClassRef e : o.getExtendsList()) { if (isAssignableFrom(e.getDefinition())) { return true; } } for (ClassRef i : o.getImplementsList()) { if (isAssignableFrom(i.getDefinition())) { return true; } } return false; }
while (target != null && !io.sundr.codegen.Constants.OBJECT.equals(target) && BuilderUtils.isBuildable(target)) { for (Property property : target.getProperties()) { if (!hasBuildableConstructorWithArgument(target, property) && Setter.has(target, property)) {
public static boolean hasOrInherits(TypeDef clazz, Property property) { TypeDef current = clazz; //Iterate parent objects and check for properties with setters but not ctor arguments. while (current!= null && !current.equals(TypeDef.OBJECT)) { for (Method method : current.getMethods()) { if (isApplicable(method, property)) { return true; } } if (!current.getExtendsList().isEmpty()) { String fqn = current.getExtendsList().iterator().next().getDefinition().getFullyQualifiedName(); current = DefinitionRepository.getRepository().getDefinition(fqn); } else { current = null; } } return false; } }
while (current!= null && !current.equals(TypeDef.OBJECT)) {
for (Method method : t.getMethods()) { if (Getter.is(method) || t.equals(item)) { String name = Getter.propertyNameSafe(method); TypeRef returnType = method.getReturnType();
.build()); if (type.equals(returnType)) { constructors.add(new MethodBuilder() .withReturnType(inlineTypeRef)