Search in sources :

Example 26 with Type

use of com.mysema.codegen.model.Type in project querydsl by querydsl.

the class Generic2Test method resolve2.

@Test
public void resolve2() {
    TypeFactory factory = new TypeFactory(Collections.<Class<? extends Annotation>>emptyList());
    Type type = factory.getEntityType(AbstractCollectionAttribute.class);
    assertEquals("com.querydsl.codegen.Generic2Test.AbstractCollectionAttribute<? extends java.util.Collection<?>>", type.getGenericName(false));
    assertEquals("com.querydsl.codegen.Generic2Test.AbstractCollectionAttribute<? extends java.util.Collection<?>>", type.getGenericName(true));
}
Also used : Type(com.mysema.codegen.model.Type) Test(org.junit.Test)

Example 27 with Type

use of com.mysema.codegen.model.Type in project querydsl by querydsl.

the class Inheritance2Test method base_base.

@Test
public void base_base() throws SecurityException, NoSuchFieldException {
    TypeFactory typeFactory = new TypeFactory();
    Field field = Base.class.getDeclaredField("base");
    Type type = typeFactory.get(field.getType(), field.getGenericType());
    assertEquals(0, type.getParameters().size());
}
Also used : Field(java.lang.reflect.Field) Type(com.mysema.codegen.model.Type) Test(org.junit.Test)

Example 28 with Type

use of com.mysema.codegen.model.Type in project querydsl by querydsl.

the class Inheritance2Test method base_base2.

@Test
public void base_base2() throws SecurityException, NoSuchFieldException {
    TypeFactory typeFactory = new TypeFactory();
    Field field = Base.class.getDeclaredField("base2");
    Type type = typeFactory.get(field.getType(), field.getGenericType());
    assertEquals(2, type.getParameters().size());
    assertNull(((TypeExtends) type.getParameters().get(0)).getVarName());
    assertNull(((TypeExtends) type.getParameters().get(1)).getVarName());
}
Also used : Field(java.lang.reflect.Field) Type(com.mysema.codegen.model.Type) Test(org.junit.Test)

Example 29 with Type

use of com.mysema.codegen.model.Type in project querydsl by querydsl.

the class TypeResolver method resolveWithParameters.

private static Type resolveWithParameters(Type type, Type declaringType, EntityType context) {
    Type[] params = new Type[type.getParameters().size()];
    boolean transformed = false;
    for (int i = 0; i < type.getParameters().size(); i++) {
        Type param = type.getParameters().get(i);
        if (param != null && !param.getFullName().equals(type.getFullName())) {
            params[i] = resolve(param, declaringType, context);
            if (!params[i].equals(param)) {
                transformed = true;
            }
        }
    }
    if (transformed) {
        return new SimpleType(type, params);
    } else {
        return type;
    }
}
Also used : SimpleType(com.mysema.codegen.model.SimpleType) Type(com.mysema.codegen.model.Type) SimpleType(com.mysema.codegen.model.SimpleType)

Example 30 with Type

use of com.mysema.codegen.model.Type in project querydsl by querydsl.

the class PropertyTest method escapedName.

@Test
public void escapedName() {
    Type typeModel = new SimpleType(TypeCategory.ENTITY, "com.querydsl.DomainClass", "com.querydsl", "DomainClass", false, false);
    EntityType type = new EntityType(typeModel);
    Property property = new Property(type, "boolean", type, Collections.<String>emptyList());
    assertEquals("boolean$", property.getEscapedName());
}
Also used : SimpleType(com.mysema.codegen.model.SimpleType) Type(com.mysema.codegen.model.Type) SimpleType(com.mysema.codegen.model.SimpleType) Test(org.junit.Test)

Aggregations

Type (com.mysema.codegen.model.Type)31 SimpleType (com.mysema.codegen.model.SimpleType)11 EntityType (com.querydsl.codegen.EntityType)8 Test (org.junit.Test)8 ClassType (com.mysema.codegen.model.ClassType)6 PropertyType (com.querydsl.core.annotations.PropertyType)5 QueryType (com.querydsl.core.annotations.QueryType)5 Parameter (com.mysema.codegen.model.Parameter)4 TypeCategory (com.mysema.codegen.model.TypeCategory)4 Property (com.querydsl.codegen.Property)4 AnnotatedElement (java.lang.reflect.AnnotatedElement)3 DeclaredType (javax.lang.model.type.DeclaredType)3 NoType (javax.lang.model.type.NoType)3 Annotation (java.lang.annotation.Annotation)2 Field (java.lang.reflect.Field)2 MappingException (org.hibernate.MappingException)2 org.hibernate.mapping (org.hibernate.mapping)2 JavaWriter (com.mysema.codegen.JavaWriter)1 ScalaWriter (com.mysema.codegen.ScalaWriter)1 QueryDelegate (com.querydsl.core.annotations.QueryDelegate)1