Package com.mysema.codegen

Examples of com.mysema.codegen.ScalaWriter


        classes.add(DateExpression.class);
        classes.add(EnumExpression.class);
        classes.add(NumberExpression.class);
       
        StringWriter w = new StringWriter();
        ScalaWriter writer = new ScalaWriter(w);
        writer.packageDecl("com.mysema.query.scala");
        writer.imports(Expression.class.getPackage());
        for (Class<?> cl : classes) {
            Type type = new ClassType(cl);
            Type superClass = new ClassType(cl.getSuperclass());
            writer.beginClass(type, superClass);
            for (Method m : cl.getDeclaredMethods()) {
                List<Parameter> params = new ArrayList<Parameter>();
                for (Class<?> paramType : m.getParameterTypes()) {
                    params.add(new Parameter("arg"+params.size(), new ClassType(paramType)));
                }
                Type returnType = new ClassType(m.getReturnType());
                writer.beginPublicMethod(returnType, ":"+m.getName(), params.toArray(new Parameter[params.size()]));
                writer.end();
            }
            writer.end();
        }
       
        System.out.println(w);
    }
View Full Code Here


    private void write(Serializer serializer, String path, EntityType type) throws IOException {
        File targetFile = new File(targetFolder, path);
        classes.add(targetFile.getPath());
        StringWriter w = new StringWriter();
        CodeWriter writer = createScalaSources ? new ScalaWriter(w) : new JavaWriter(w);
        serializer.serialize(type, SimpleSerializerConfig.DEFAULT, writer);

        // conditional creation
        boolean generate = true;
        byte[] bytes = w.toString().getBytes(sourceEncoding);
View Full Code Here

            EntityType type) throws IOException {
        File targetFile = new File(targetFolder, path);
        generatedFiles.add(targetFile);
        Writer w = writerFor(targetFile);
        try {
            CodeWriter writer = createScalaSources ? new ScalaWriter(w) : new JavaWriter(w);
            serializer.serialize(type, serializerConfig, writer);
        } finally {
            w.close();
        }
    }
View Full Code Here

TOP

Related Classes of com.mysema.codegen.ScalaWriter

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.