Package com.mysema.codegen

Examples of com.mysema.codegen.JavaWriter


                JavaFileObject fileObject = processingEnv.getFiler().createSourceFile(className,
                        elements.toArray(new Element[elements.size()]));
                Writer writer = fileObject.openWriter();
                try {
                    SerializerConfig serializerConfig = conf.getSerializerConfig(model);
                    serializer.serialize(model, serializerConfig, new JavaWriter(writer));
                } finally {
                    if (writer != null) {
                        writer.close();
                    }
                }
View Full Code Here


    private void write(Serializer serializer, String path, EntityType type) throws IOException {
        File targetFile = new File(targetFolder, path);
        generatedFiles.add(targetFile);
        Writer w = writerFor(targetFile);
        try{
            CodeWriter writer = new JavaWriter(w);
            serializer.serialize(type, serializerConfig, writer);
        }finally{
            w.close();
        }
    }
View Full Code Here

            Type classType = new ClassType(TypeCategory.get(cl.getName()), cl);
            type.addProperty(new Property(type, StringUtils.uncapitalize(cl.getSimpleName()), classType));
        }

        GroovyBeanSerializer serializer = new GroovyBeanSerializer();
        serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
        String str = writer.toString();
        //System.err.println(str);
        for (String prop : Arrays.asList(
                "String[] arrayField;",
                "Boolean boolean$;",
View Full Code Here

    @Test
    public void Javadocs_For_InnerClass() throws IOException{
        EntityType entityType = new EntityType(new ClassType(Entity.class));
        typeMappings.register(entityType, queryTypeFactory.create(entityType));

        serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
        assertTrue(writer.toString().contains("QEntitySerializerTest_Entity is a Querydsl query type for Entity"));
    }
View Full Code Here

        queryTypeFactory = new QueryTypeFactoryImpl("Q", "", ".gen");
       
        EntityType entityType = new EntityType(new ClassType(Entity.class));
        typeMappings.register(entityType, queryTypeFactory.create(entityType));
       
        serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));       
//        System.err.println(writer.toString());
        assertTrue(writer.toString().contains("public class QEntitySerializerTest_Entity " +
            "extends EntityPathBase<EntitySerializerTest.Entity>"));
    }
View Full Code Here

    public void No_Package() throws IOException {
        SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity",false,false);
        EntityType entityType = new EntityType(type);
        typeMappings.register(entityType, queryTypeFactory.create(entityType));

        serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
        assertTrue(writer.toString().contains("public class QEntity extends EntityPathBase<Entity> {"));
    }
View Full Code Here

        for (Map.Entry<TypeCategory, String> entry : categoryToSuperClass.entrySet()) {
            SimpleType type = new SimpleType(entry.getKey(), "Entity", "", "Entity",false,false);
            EntityType entityType = new EntityType(type);
            typeMappings.register(entityType, queryTypeFactory.create(entityType));

            serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
            assertTrue(entry.toString(), writer.toString().contains("public class QEntity extends "+entry.getValue()+" {"));
        }

    }
View Full Code Here

    public void Correct_Superclass() throws IOException {
        SimpleType type = new SimpleType(TypeCategory.ENTITY, "java.util.Locale", "java.util", "Locale",false,false);
        EntityType entityType = new EntityType(type);
        typeMappings.register(entityType, queryTypeFactory.create(entityType));

        serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
//        System.out.println(writer);
        assertTrue(writer.toString().contains("public class QLocale extends EntityPathBase<Locale> {"));
    }
View Full Code Here

    @Test
    public void Primitive_Array() throws IOException{
        SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity",false,false);
        EntityType entityType = new EntityType(type);
        entityType.addProperty(new Property(entityType, "bytes", new ClassType(byte[].class)));
        serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
        assertTrue(writer.toString().contains("public final SimplePath<byte[]> bytes"));
    }
View Full Code Here

        entityType.addProperty(new Property(entityType, "t", new ClassType(TypeCategory.TIME, Time.class)));

        EntityType subType = new EntityType(new SimpleType(TypeCategory.ENTITY, "Entity2", "", "Entity2",false,false));
        subType.include(new Supertype(type,entityType));

        serializer.serialize(subType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
        // TODO : assertions
    }
View Full Code Here

TOP

Related Classes of com.mysema.codegen.JavaWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.