Search in sources :

Example 21 with ClassType

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

the class EntityTypeTest method uncapSimpleName_escaped.

@Test
public void uncapSimpleName_escaped() {
    ClassType typeModel = new ClassType(TypeCategory.ENTITY, Object.class);
    EntityType entityModel = new EntityType(typeModel);
    assertEquals("object", entityModel.getModifiedSimpleName());
    entityModel.addProperty(new Property(entityModel, "object", typeModel));
    assertEquals("object1", entityModel.getModifiedSimpleName());
}
Also used : ClassType(com.querydsl.codegen.utils.model.ClassType) Test(org.junit.Test)

Example 22 with ClassType

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

the class DefaultEmbeddableSerializer method introClassHeader.

@Override
@SuppressWarnings(UNCHECKED)
protected void introClassHeader(CodeWriter writer, EntityType model) throws IOException {
    Type queryType = typeMappings.getPathType(model, model, true);
    TypeCategory category = model.getOriginalCategory();
    Class<? extends Path> pathType;
    if (model.getProperties().isEmpty()) {
        switch(category) {
            case COMPARABLE:
                pathType = ComparablePath.class;
                break;
            case ENUM:
                pathType = EnumPath.class;
                break;
            case DATE:
                pathType = DatePath.class;
                break;
            case DATETIME:
                pathType = DateTimePath.class;
                break;
            case TIME:
                pathType = TimePath.class;
                break;
            case NUMERIC:
                pathType = NumberPath.class;
                break;
            case STRING:
                pathType = StringPath.class;
                break;
            case BOOLEAN:
                pathType = BooleanPath.class;
                break;
            default:
                pathType = BeanPath.class;
        }
    } else {
        pathType = BeanPath.class;
    }
    for (Annotation annotation : model.getAnnotations()) {
        writer.annotation(annotation);
    }
    writer.line("@", generatedAnnotationClass.getSimpleName(), "(\"", getClass().getName(), "\")");
    if (category == TypeCategory.BOOLEAN || category == TypeCategory.STRING) {
        writer.beginClass(queryType, new ClassType(pathType));
    } else {
        writer.beginClass(queryType, new ClassType(category, pathType, model));
    }
    // TODO : generate proper serialVersionUID here
    writer.privateStaticFinal(Types.LONG_P, "serialVersionUID", model.hashCode() + "L");
}
Also used : Type(com.querydsl.codegen.utils.model.Type) ClassType(com.querydsl.codegen.utils.model.ClassType) TypeCategory(com.querydsl.codegen.utils.model.TypeCategory) ClassType(com.querydsl.codegen.utils.model.ClassType) Annotation(java.lang.annotation.Annotation)

Example 23 with ClassType

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

the class ScalaWriterTest method Arrays.

@Test
public void Arrays() throws IOException {
    // def main(args: Array[String]) {
    writer.beginClass(new SimpleType("Main"));
    writer.field(Types.STRING.asArrayType(), "stringArray");
    writer.beginPublicMethod(Types.VOID, "main", new Parameter("args", Types.STRING.asArrayType()));
    writer.line("//");
    writer.end();
    writer.beginPublicMethod(Types.VOID, "main2", new Parameter("args", new ClassType(TypeCategory.ARRAY, String[].class)));
    writer.line("//");
    writer.end();
    writer.end();
    System.out.println(w);
    assertTrue(w.toString().contains("var stringArray: Array[String]"));
    assertTrue(w.toString().contains("def main(args: Array[String])"));
    assertTrue(w.toString().contains("def main2(args: Array[String])"));
}
Also used : SimpleType(com.querydsl.codegen.utils.model.SimpleType) Parameter(com.querydsl.codegen.utils.model.Parameter) ClassType(com.querydsl.codegen.utils.model.ClassType) Test(org.junit.Test)

Example 24 with ClassType

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

the class JavaWriterTest method Primitive_Arrays.

@Test
public void Primitive_Arrays() {
    ClassType byteArray = new ClassType(byte[].class);
    assertEquals("byte[]", writer.getRawName(byteArray));
}
Also used : ClassType(com.querydsl.codegen.utils.model.ClassType) Test(org.junit.Test)

Example 25 with ClassType

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

the class InnerClassesTest method DirectParameter.

@Test
public void DirectParameter() throws IOException {
    Type entityType = new ClassType(Entity.class);
    Type type = new SimpleType("com.querydsl.codegen.utils.gen.QEntity", "com.querydsl.codegen.utils.gen", "QEntity", entityType);
    StringWriter str = new StringWriter();
    JavaWriter writer = new JavaWriter(str);
    writer.beginClass(type);
    writer.end();
    System.err.println(str.toString());
}
Also used : SimpleType(com.querydsl.codegen.utils.model.SimpleType) Type(com.querydsl.codegen.utils.model.Type) ClassType(com.querydsl.codegen.utils.model.ClassType) SimpleType(com.querydsl.codegen.utils.model.SimpleType) StringWriter(java.io.StringWriter) ClassType(com.querydsl.codegen.utils.model.ClassType) Test(org.junit.Test)

Aggregations

ClassType (com.querydsl.codegen.utils.model.ClassType)35 Test (org.junit.Test)24 SimpleType (com.querydsl.codegen.utils.model.SimpleType)18 Type (com.querydsl.codegen.utils.model.Type)14 List (java.util.List)7 JavaWriter (com.querydsl.codegen.utils.JavaWriter)6 StringWriter (java.io.StringWriter)6 Parameter (com.querydsl.codegen.utils.model.Parameter)4 TypeCategory (com.querydsl.codegen.utils.model.TypeCategory)3 PrimaryKeyData (com.querydsl.sql.codegen.support.PrimaryKeyData)3 ArrayList (java.util.ArrayList)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 Property (com.querydsl.codegen.Property)2 Cat (com.querydsl.codegen.utils.support.Cat)2 JoinType (com.querydsl.core.JoinType)2 ColumnImpl (com.querydsl.sql.ColumnImpl)2 Annotation (java.lang.annotation.Annotation)2 Before (org.junit.Before)2 EntityType (com.querydsl.codegen.EntityType)1 ScalaWriter (com.querydsl.codegen.utils.ScalaWriter)1