private static TypeRef getKeyForValue(Map<TypeRef, TypeParamDef> map, TypeRef value) { for (Map.Entry<TypeRef, TypeParamDef> entry : map.entrySet()) { if (value instanceof TypeParamRef && ((TypeParamRef) value).getName().equals(entry.getValue().getName())) { return entry.getKey(); } } return null; //throw new IllegalStateException("Key not found for value:[" + value +"]."); }
private static boolean containsValue(Map<TypeRef, TypeParamDef> map, TypeRef value) { for (Map.Entry<TypeRef, TypeParamDef> entry : map.entrySet()) { if (value instanceof TypeParamRef && ((TypeParamRef) value).getName().equals(entry.getValue().getName())) { return true; } } return false; }
public static Set<String> allGenericsOf(TypeRef type) { Set<String> result = new HashSet<String>(); if (type instanceof ClassRef) { for (TypeRef ref : ((ClassRef)type).getArguments()) { if (ref instanceof TypeParamRef) { result.add(((TypeParamRef)ref).getName()); } } } return result; }
public static TypeParamDef getParameterDefinition(TypeRef typeRef, Collection<TypeParamDef> parameters) { String name; if (typeRef instanceof ClassRef) { name = ((ClassRef)typeRef).getName(); } else if (typeRef instanceof TypeParamRef) { name = ((TypeParamRef)typeRef).getName(); } else if (typeRef instanceof PrimitiveRef) { name = ((PrimitiveRef)typeRef).getName(); } else { name = typeRef.toString(); } for (TypeParamDef parameter : parameters) { if (parameter.getName().equals(name)) { return parameter; } } return null; }
public TypeParamRefBuilder(TypeParamRefFluent<?> fluent, TypeParamRef instance, Boolean validationEnabled) { this.fluent = fluent; fluent.withName(instance.getName()); fluent.withDimensions(instance.getDimensions()); fluent.withAttributes(instance.getAttributes()); this.validationEnabled = validationEnabled; }
public TypeParamRefBuilder(TypeParamRef instance, Boolean validationEnabled) { this.fluent = this; this.withName(instance.getName()); this.withDimensions(instance.getDimensions()); this.withAttributes(instance.getAttributes()); this.validationEnabled = validationEnabled; }
private static final Set<TypeParamDef> extractParameters(ClassRef classRef) { final Set<TypeParamDef> result = new LinkedHashSet<TypeParamDef>(); final Set<TypeParamRef> refs = new LinkedHashSet<TypeParamRef>(); ClassRef ignored = new ClassRefBuilder(classRef).accept(new TypeParamDefColletor(result)).accept(new TypeParamRefColletor(refs)).build(); for (TypeParamRef typeParamRef : refs) { result.add(new TypeParamDefBuilder().withName(typeParamRef.getName()).withAttributes(typeParamRef.getAttributes()).build()); } return result; }
public TypeParamRefFluentImpl(TypeParamRef instance){ this.withName(instance.getName()); this.withDimensions(instance.getDimensions()); this.withAttributes(instance.getAttributes()); }
private static final Set<TypeParamDef> extractParameters(TypeDef typeDef) { final Set<TypeParamDef> result = new LinkedHashSet<TypeParamDef>(); final Set<TypeParamRef> refs = new LinkedHashSet<TypeParamRef>(); TypeDef ignored = new TypeDefBuilder(typeDef).accept(new TypeParamDefColletor(result)).accept(new TypeParamRefColletor(refs)).build(); for (TypeParamRef typeParamRef : refs) { result.add(new TypeParamDefBuilder().withName(typeParamRef.getName()).withAttributes(typeParamRef.getAttributes()).build()); } return result; }