TypeVariable tv = (TypeVariable) genericType; if (tv.getBounds().length == 1 && tv.getBounds()[0].equals(Object.class)) { value = new TypeSuper(tv.getName(), value); } else { value = new TypeExtends(tv.getName(), value);
private static String getVarName(Type type) { if (type instanceof TypeExtends) { return ((TypeExtends) type).getVarName(); } else if (type instanceof TypeSuper) { return ((TypeSuper) type).getVarName(); } else { return null; } }
@Override public String getGenericName(boolean asArgType) { return getGenericName(asArgType, Collections.<String> emptySet(), Collections.<String> emptySet()); }
@Override public Type visitTypeVariable(TypeVariable typeVariable, Boolean p) { String varName = typeVariable.toString(); if (typeVariable.getUpperBound() != null) { Type type = visit(typeVariable.getUpperBound(), p); return new TypeExtends(varName, type); } else if (typeVariable.getLowerBound() != null && !(typeVariable.getLowerBound() instanceof NullType)) { Type type = visit(typeVariable.getLowerBound(), p); return new TypeSuper(varName, type); } else { return null; } }
@Override public Type visitWildcard(WildcardType wildcardType, Boolean p) { if (wildcardType.getExtendsBound() != null) { Type type = visit(wildcardType.getExtendsBound(), p); return new TypeExtends(type); } else if (wildcardType.getSuperBound() != null) { Type type = visit(wildcardType.getSuperBound(), p); return new TypeSuper(type); } else { return null; } }
@SuppressWarnings("unchecked") @Before public void setUp() { // type Type typeModel = new SimpleType(TypeCategory.ENTITY, "com.querydsl.DomainClass", "com.querydsl", "DomainClass", false, false); type = new EntityType(typeModel); // property type.addProperty(new Property(type, "entityField", type)); type.addProperty(new Property(type, "collection", new ClassType(TypeCategory.COLLECTION, Collection.class, typeModel))); type.addProperty(new Property(type, "listField", new ClassType(TypeCategory.LIST, List.class, typeModel))); type.addProperty(new Property(type, "setField", new ClassType(TypeCategory.SET, Set.class, typeModel))); type.addProperty(new Property(type, "arrayField", new ClassType(TypeCategory.ARRAY, String[].class, typeModel))); type.addProperty(new Property(type, "mapField", new ClassType(TypeCategory.MAP, List.class, typeModel, typeModel))); type.addProperty(new Property(type, "superTypeField", new TypeExtends(new ClassType(TypeCategory.MAP, List.class, typeModel, typeModel)))); type.addProperty(new Property(type, "extendsTypeField", new TypeSuper(new ClassType(TypeCategory.MAP, List.class, typeModel, typeModel)))); for (Class<?> cl : Arrays.asList(Boolean.class, Comparable.class, Integer.class, Date.class, java.sql.Date.class, java.sql.Time.class)) { Type classType = new ClassType(TypeCategory.get(cl.getName()), cl); type.addProperty(new Property(type, StringUtils.uncapitalize(cl.getSimpleName()), classType)); } // constructor Parameter firstName = new Parameter("firstName", new ClassType(TypeCategory.STRING, String.class)); Parameter lastName = new Parameter("lastName", new ClassType(TypeCategory.STRING, String.class)); type.addConstructor(new Constructor(Arrays.asList(firstName, lastName))); }
@SuppressWarnings("unchecked") @Before public void setUp() { // type Type typeModel = new SimpleType(TypeCategory.ENTITY, "com.querydsl.DomainClass", "com.querydsl", "DomainClass", false, false); type = new EntityType(typeModel); // property type.addProperty(new Property(type, "entityField", type)); type.addProperty(new Property(type, "collection", new ClassType(TypeCategory.COLLECTION, Collection.class, typeModel))); type.addProperty(new Property(type, "listField", new ClassType(TypeCategory.LIST, List.class, typeModel))); type.addProperty(new Property(type, "setField", new ClassType(TypeCategory.SET, Set.class, typeModel))); type.addProperty(new Property(type, "arrayField", new ClassType(TypeCategory.ARRAY, String[].class, typeModel))); type.addProperty(new Property(type, "mapField", new ClassType(TypeCategory.MAP, List.class, typeModel, typeModel))); type.addProperty(new Property(type, "superTypeField", new TypeExtends(new ClassType(TypeCategory.MAP, List.class, typeModel, typeModel)))); type.addProperty(new Property(type, "extendsTypeField", new TypeSuper(new ClassType(TypeCategory.MAP, List.class, typeModel, typeModel)))); for (Class<?> cl : Arrays.asList(Boolean.class, Comparable.class, Integer.class, Date.class, java.sql.Date.class, java.sql.Time.class)) { Type classType = new ClassType(TypeCategory.get(cl.getName()), cl); type.addProperty(new Property(type, StringUtils.uncapitalize(cl.getSimpleName()), classType)); } // constructor Parameter firstName = new Parameter("firstName", new ClassType(TypeCategory.STRING, String.class)); Parameter lastName = new Parameter("lastName", new ClassType(TypeCategory.STRING, String.class)); type.addConstructor(new Constructor(Arrays.asList(firstName, lastName))); }
@SuppressWarnings("unchecked") @Before public void setUp() { // type Type typeModel = new SimpleType(TypeCategory.ENTITY, "com.mysema.query.DomainClass", "com.mysema.query", "DomainClass", false, false); type = new EntityType(typeModel); // property type.addProperty(new Property(type, "entityField", type)); type.addProperty(new Property(type, "collection", new ClassType(TypeCategory.COLLECTION, Collection.class, typeModel))); type.addProperty(new Property(type, "listField", new ClassType(TypeCategory.LIST, List.class, typeModel))); type.addProperty(new Property(type, "setField", new ClassType(TypeCategory.SET, Set.class, typeModel))); type.addProperty(new Property(type, "arrayField", new ClassType(TypeCategory.ARRAY, String[].class, typeModel))); type.addProperty(new Property(type, "mapField", new ClassType(TypeCategory.MAP, List.class, typeModel, typeModel))); type.addProperty(new Property(type, "superTypeField", new TypeExtends(new ClassType(TypeCategory.MAP, List.class, typeModel, typeModel)))); type.addProperty(new Property(type, "extendsTypeField", new TypeSuper(new ClassType(TypeCategory.MAP, List.class, typeModel, typeModel)))); for (Class<?> cl : Arrays.asList(Boolean.class, Comparable.class, Integer.class, Date.class, java.sql.Date.class, java.sql.Time.class)) { Type classType = new ClassType(TypeCategory.get(cl.getName()), cl); type.addProperty(new Property(type, StringUtils.uncapitalize(cl.getSimpleName()), classType)); } // constructor Parameter firstName = new Parameter("firstName", new ClassType(TypeCategory.STRING, String.class)); Parameter lastName = new Parameter("lastName", new ClassType(TypeCategory.STRING, String.class)); type.addConstructor(new Constructor(Arrays.asList(firstName, lastName))); }