private static Set<TypeParamDef> findParameters(Set<TypeDef> interfaces) { if (interfaces.size() < 2) { return Collections.<TypeParamDef>emptySet(); } //1st pass find all generics Set<TypeParamDef> allGenerics = new LinkedHashSet<TypeParamDef>(); for (TypeDef clazz : interfaces) { allGenerics.addAll(clazz.getParameters()); } //2nd pass collect common generics Set<TypeParamDef> common = new LinkedHashSet<TypeParamDef>(allGenerics); for (TypeDef clazz : interfaces) { Set<TypeParamDef> ownGenerics = new LinkedHashSet<TypeParamDef>(); ownGenerics.addAll(clazz.getParameters()); common.remove(clazz); common.retainAll(ownGenerics); } Set<TypeParamDef> result = new LinkedHashSet<TypeParamDef>(); for (TypeParamDef type : common) { Boolean isGeneric = type.getAttributes().containsKey(IS_GENERIC) ? (Boolean) type.getAttributes().get(IS_GENERIC) : false; if (!isGeneric) { result.add(type); } } return result; } }
public TypeParamRef toReference() { return new TypeParamRefBuilder() .withName(name) .withAttributes(getAttributes()) .build(); }
public TypeParamDefFluentImpl(TypeParamDef instance){ this.withName(instance.getName()); this.withBounds(instance.getBounds()); this.withAttributes(instance.getAttributes()); }
public TypeParamDefBuilder(TypeParamDefFluent<?> fluent, TypeParamDef instance) { this.fluent = fluent; fluent.withName(instance.getName()); fluent.withBounds(instance.getBounds()); fluent.withAttributes(instance.getAttributes()); }
public TypeParamDefBuilder(TypeParamDef instance) { this.fluent = this; this.withName(instance.getName()); this.withBounds(instance.getBounds()); this.withAttributes(instance.getAttributes()); }