Search in sources :

Example 21 with SimpleType

use of com.querydsl.codegen.utils.model.SimpleType 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)

Example 22 with SimpleType

use of com.querydsl.codegen.utils.model.SimpleType 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 23 with SimpleType

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

the class ScalaWriterTest method Trait.

@Test
public void Trait() throws IOException {
    // trait MyTrait
    writer.beginInterface(new SimpleType("MyTrait"));
    writer.line("//");
    writer.end();
    System.out.println(w);
    assertTrue(w.toString().contains("trait MyTrait"));
}
Also used : SimpleType(com.querydsl.codegen.utils.model.SimpleType) Test(org.junit.Test)

Example 24 with SimpleType

use of com.querydsl.codegen.utils.model.SimpleType 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.querydsl.codegen.utils.model.SimpleType) Type(com.querydsl.codegen.utils.model.Type) SimpleType(com.querydsl.codegen.utils.model.SimpleType)

Example 25 with SimpleType

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

the class ExtendedBeanSerializerTest method setUp.

@Before
public void setUp() throws IOException {
    Type typeModel = new SimpleType(TypeCategory.ENTITY, FULL_NAME, PACKAGE, CLASS_NAME, false, false);
    type = new EntityType(typeModel);
    File srcFolder = compileFolder.newFolder(PATH);
    srcFile = new File(srcFolder, CLASS_NAME + ".java");
}
Also used : EntityType(com.querydsl.codegen.EntityType) SimpleType(com.querydsl.codegen.utils.model.SimpleType) EntityType(com.querydsl.codegen.EntityType) SimpleType(com.querydsl.codegen.utils.model.SimpleType) Type(com.querydsl.codegen.utils.model.Type) ClassType(com.querydsl.codegen.utils.model.ClassType) File(java.io.File) Before(org.junit.Before)

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