Search in sources :

Example 16 with SimpleType

use of com.querydsl.codegen.utils.model.SimpleType in project querydsl by querydsl.

the class BeanSerializerTest method setUp.

@Before
public void setUp() {
    typeModel = new SimpleType(TypeCategory.ENTITY, "com.querydsl.DomainClass", "com.querydsl", "DomainClass", false, false);
    type = new EntityType(typeModel);
}
Also used : SimpleType(com.querydsl.codegen.utils.model.SimpleType) Before(org.junit.Before)

Example 17 with SimpleType

use of com.querydsl.codegen.utils.model.SimpleType in project querydsl by querydsl.

the class TypeMappingsTest method testGenericTypeRegistration.

@Test
public void testGenericTypeRegistration() {
    SimpleType rawListType = new SimpleType(List.class.getName());
    SimpleType integerListType = new SimpleType(rawListType, Collections.<Type>singletonList(new SimpleType(Integer.class.getName())));
    SimpleType longListType = new SimpleType(rawListType, Collections.<Type>singletonList(new SimpleType(Long.class.getName())));
    SimpleType integerListTypeExpression = new SimpleType("integerListTypeExpression");
    SimpleType longListTypeExpression = new SimpleType("longListTypeExpression");
    TypeMappings typeMappings = new JavaTypeMappings();
    typeMappings.register(integerListType, integerListTypeExpression);
    typeMappings.register(longListType, longListTypeExpression);
    assertEquals(integerListTypeExpression, typeMappings.getExprType(integerListType, null, false));
    assertEquals(longListTypeExpression, typeMappings.getExprType(longListType, null, false));
}
Also used : SimpleType(com.querydsl.codegen.utils.model.SimpleType) List(java.util.List) Test(org.junit.Test)

Example 18 with SimpleType

use of com.querydsl.codegen.utils.model.SimpleType in project querydsl by querydsl.

the class PropertyTest method equals_and_hashCode.

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

Example 19 with SimpleType

use of com.querydsl.codegen.utils.model.SimpleType in project querydsl by querydsl.

the class MetaDataTest method setUp.

@Before
public void setUp() {
    NamingStrategy namingStrategy = new DefaultNamingStrategy();
    String packageName = "com.myproject.domain";
    String tableName = "vwServiceName";
    String className = namingStrategy.getClassName(tableName);
    Type classTypeModel = new SimpleType(TypeCategory.ENTITY, packageName + "." + className, packageName, className, false, false);
    classModel = new EntityType(classTypeModel);
    // classModel.addAnnotation(new TableImpl(namingStrategy.normalizeTableName(tableName)));
    classModel.getData().put("table", namingStrategy.normalizeTableName(tableName));
}
Also used : EntityType(com.querydsl.codegen.EntityType) SimpleType(com.querydsl.codegen.utils.model.SimpleType) Type(com.querydsl.codegen.utils.model.Type) EntityType(com.querydsl.codegen.EntityType) SimpleType(com.querydsl.codegen.utils.model.SimpleType) Before(org.junit.Before)

Example 20 with SimpleType

use of com.querydsl.codegen.utils.model.SimpleType in project querydsl by querydsl.

the class ExtendedTypeFactory method createMapType.

protected Type createMapType(Iterator<? extends TypeMirror> typeMirrors, boolean deep) {
    if (!typeMirrors.hasNext()) {
        return new SimpleType(Types.MAP, defaultType, defaultType);
    }
    Type keyType = getType(typeMirrors.next(), deep);
    if (keyType == null) {
        keyType = defaultType;
    }
    Type valueType = getType(typeMirrors.next(), deep);
    if (valueType == null) {
        valueType = defaultType;
    } else if (valueType.getParameters().isEmpty()) {
        TypeElement element = env.getElementUtils().getTypeElement(valueType.getFullName());
        if (element != null) {
            Type type = getType(element.asType(), deep);
            if (!type.getParameters().isEmpty()) {
                valueType = new SimpleType(valueType, new Type[type.getParameters().size()]);
            }
        }
    }
    return new SimpleType(Types.MAP, keyType, valueType);
}
Also used : SimpleType(com.querydsl.codegen.utils.model.SimpleType) ErrorType(javax.lang.model.type.ErrorType) EntityType(com.querydsl.codegen.EntityType) DeclaredType(javax.lang.model.type.DeclaredType) SimpleType(com.querydsl.codegen.utils.model.SimpleType) WildcardType(javax.lang.model.type.WildcardType) ArrayType(javax.lang.model.type.ArrayType) Type(com.querydsl.codegen.utils.model.Type) ExecutableType(javax.lang.model.type.ExecutableType) NoType(javax.lang.model.type.NoType) NullType(javax.lang.model.type.NullType) PrimitiveType(javax.lang.model.type.PrimitiveType) TypeElement(javax.lang.model.element.TypeElement)

Aggregations

SimpleType (com.querydsl.codegen.utils.model.SimpleType)35 Type (com.querydsl.codegen.utils.model.Type)17 Test (org.junit.Test)17 ClassType (com.querydsl.codegen.utils.model.ClassType)15 JavaWriter (com.querydsl.codegen.utils.JavaWriter)8 StringWriter (java.io.StringWriter)6 EntityType (com.querydsl.codegen.EntityType)5 Parameter (com.querydsl.codegen.utils.model.Parameter)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 Before (org.junit.Before)5 File (java.io.File)3 Writer (java.io.Writer)3 Map (java.util.Map)3 BeanSerializer (com.querydsl.codegen.BeanSerializer)2 Configuration (com.querydsl.sql.Configuration)2 MetaDataExporter (com.querydsl.sql.codegen.MetaDataExporter)2 NumericMapping (com.querydsl.sql.codegen.support.NumericMapping)2 RenameMapping (com.querydsl.sql.codegen.support.RenameMapping)2 TypeMapping (com.querydsl.sql.codegen.support.TypeMapping)2 Connection (java.sql.Connection)2