public static void visitParents(TypeDef type, List<TypeDef> types, List<TypeDef> visited) { if (type == null || JAVA_LANG_OBJECT.equals(type.getFullyQualifiedName())) { return; } if (visited.contains(type)) { return; } visited.add(type); List<TypeRef> allRefs = new ArrayList<>(); allRefs.addAll(type.getImplementsList()); allRefs.addAll(type.getExtendsList()); for (TypeRef ref : allRefs) { TypeDef parent = DefinitionRepository.getRepository().getDefinition(ref); visitParents(parent, types, visited); } types.add(type); } }
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; }
/** * Checks if a {@link TypeDef} is an instance of an other {@link TypeDef}. * @param type The type to compare. * @param targetType The target type. * @param function * @return true if match, false otherwise. */ public static boolean isInstanceOf(TypeRef type, TypeDef targetType, Function<TypeRef, Boolean> function) { if (type instanceof ClassRef) { ClassRef classRef = (ClassRef) type; TypeDef definition = classRef.getDefinition(); if (definition.getFullyQualifiedName().equals(targetType.getFullyQualifiedName())) { return true; } for (TypeRef i : definition.getImplementsList()) { if (function.apply(i)) { return true; } } for (TypeRef e : definition.getExtendsList()) { if (function.apply(e)) { return true; } } } return false; }
for (ClassRef n : nestedType.getImplementsList()) { nestedInterfaces.add(n);
for (ClassRef n : nestedType.getImplementsList()) { nestedInterfaces.add(n);
public TypeDefFluentImpl(TypeDef instance){ 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()); }
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; }
public TypeDefBuilder(TypeDefFluent<?> fluent,TypeDef instance,Boolean validationEnabled){ this.fluent = fluent; fluent.withKind(instance.getKind()); fluent.withPackageName(instance.getPackageName()); fluent.withName(instance.getName()); fluent.withComments(instance.getComments()); fluent.withAnnotations(instance.getAnnotations()); fluent.withExtendsList(instance.getExtendsList()); fluent.withImplementsList(instance.getImplementsList()); fluent.withParameters(instance.getParameters()); fluent.withProperties(instance.getProperties()); fluent.withConstructors(instance.getConstructors()); fluent.withMethods(instance.getMethods()); fluent.withOuterType(instance.getOuterType()); fluent.withInnerTypes(instance.getInnerTypes()); fluent.withModifiers(instance.getModifiers()); fluent.withAttributes(instance.getAttributes()); this.validationEnabled = validationEnabled; } public TypeDefBuilder(TypeDef instance){