Package com.asakusafw.utils.java.model.syntax

Examples of com.asakusafw.utils.java.model.syntax.ModelFactory


            EmitContext context, ModelDeclaration model) throws IOException {
        HiveDataModelTrait trait = model.getTrait(HiveDataModelTrait.class);
        if (trait == null) {
            return Collections.emptyList();
        }
        ModelFactory f = context.getModelFactory();
        List<Expression> values = new ArrayList<Expression>();
        for (Namer namer : trait.getDataFormatNamers()) {
            Name name = namer.computeName(context, model);
            values.add(f.newClassLiteral(context.resolve(name)));
        }
        return new AttributeBuilder(f)
            .annotation(context.resolve(HiveTable.class), f.newArrayInitializer(values))
            .toAnnotations();
    }
View Full Code Here


            return Collections.emptyList();
        }
        String name = HiveFieldTrait.getColumnName(property);
        TypeInfo type = HiveFieldTrait.getTypeInfo(property);
        boolean present = HiveFieldTrait.get(property).isColumnPresent();
        ModelFactory f = context.getModelFactory();
        return new AttributeBuilder(f)
            .annotation(context.resolve(HiveField.class),
                    "name", Models.toLiteral(f, name), //$NON-NLS-1$
                    "type", Models.toLiteral(f, type.getQualifiedName()), //$NON-NLS-1$
                    "ignore", Models.toLiteral(f, present == false)) //$NON-NLS-1$
View Full Code Here

                CATEGORY,
                PATTERN_FACTORY);
    }

    static Expression computeValueType(EmitContext context, PropertyDeclaration property) {
        ModelFactory f = context.getModelFactory();
        HiveFieldTrait field = HiveFieldTrait.get(property);
        switch (field.getTypeKind()) {
        case NATURAL:
            return new TypeBuilder(f, context.resolve(ValueSerdeFactory.class))
                .field(getValueSerdeNaturalName(f, (BasicType) property.getType()))
View Full Code Here

    }

    private MethodDeclaration createWrite(EmitContext context, ModelDeclaration model) {
        assert context != null;
        assert model != null;
        ModelFactory f = context.getModelFactory();
        SimpleName parameter = context.createVariableName("out"); //$NON-NLS-1$
        List<Statement> statements = Lists.create();
        for (PropertyDeclaration property : model.getDeclaredProperties()) {
            SimpleName fieldName = context.getFieldName(property);
            statements.add(new ExpressionBuilder(f, fieldName)
                .method("write", parameter) //$NON-NLS-1$
                .toStatement());
        }
        return f.newMethodDeclaration(
                null,
                new AttributeBuilder(f)
                    .annotation(context.resolve(Override.class))
                    .Public()
                    .toAttributes(),
                Collections.<TypeParameterDeclaration>emptyList(),
                Models.toType(f, void.class),
                f.newSimpleName("write"), //$NON-NLS-1$
                Collections.singletonList(f.newFormalParameterDeclaration(
                        context.resolve(DataOutput.class),
                        parameter)),
                0,
                Collections.singletonList(context.resolve(IOException.class)),
                f.newBlock(statements));
    }
View Full Code Here

    }

    private MethodDeclaration createReadFields(EmitContext context, ModelDeclaration model) {
        assert context != null;
        assert model != null;
        ModelFactory f = context.getModelFactory();
        SimpleName parameter = context.createVariableName("in"); //$NON-NLS-1$
        List<Statement> statements = Lists.create();
        for (PropertyDeclaration property : model.getDeclaredProperties()) {
            SimpleName fieldName = context.getFieldName(property);
            statements.add(new ExpressionBuilder(f, fieldName)
                .method("readFields", parameter) //$NON-NLS-1$
                .toStatement());
        }
        return f.newMethodDeclaration(
                null,
                new AttributeBuilder(f)
                    .annotation(context.resolve(Override.class))
                    .Public()
                    .toAttributes(),
                Collections.<TypeParameterDeclaration>emptyList(),
                Models.toType(f, void.class),
                f.newSimpleName("readFields"), //$NON-NLS-1$
                Arrays.asList(f.newFormalParameterDeclaration(
                        context.resolve(DataInput.class),
                        parameter)),
                0,
                Collections.singletonList(context.resolve(IOException.class)),
                f.newBlock(statements));
    }
View Full Code Here

public class ModelOutputDriver extends JavaDataModelDriver {

    @Override
    public List<Annotation> getTypeAnnotations(EmitContext context, ModelDeclaration model) throws IOException {
        Type type = generate(context, model);
        ModelFactory f = context.getModelFactory();
        return new AttributeBuilder(f)
            .annotation(context.resolve(ModelOutputLocation.class),
                    f.newClassLiteral(context.resolve(type)))
            .toAnnotations();
    }
View Full Code Here

*/
public class HelloDriver extends JavaDataModelDriver {

    @Override
    public List<MethodDeclaration> getMethods(EmitContext context, ModelDeclaration model) {
        ModelFactory f = context.getModelFactory();
        return Collections.singletonList(f.newMethodDeclaration(
                null,
                new AttributeBuilder(f)
                    .Public()
                    .toAttributes(),
                context.resolve(String.class),
                f.newSimpleName("hello"),
                Collections.<FormalParameterDeclaration>emptyList(),
                Collections.singletonList(new ExpressionBuilder(f, Models.toLiteral(f, "hello"))
                    .toReturnStatement())));
    }
View Full Code Here

        }
        return compiler.getClassLoader();
    }

    private List<VolatileJavaFile> emit(DmdlSourceRepository source) throws IOException {
        ModelFactory factory = Models.getModelFactory();
        VolatileEmitter emitter = new VolatileEmitter();
        com.asakusafw.dmdl.java.Configuration conf = new com.asakusafw.dmdl.java.Configuration(
                factory,
                source,
                Models.toName(factory, "com.example"),
View Full Code Here

        }
        return compiler.getClassLoader();
    }

    private List<VolatileJavaFile> emit(DmdlSourceRepository source) throws IOException {
        ModelFactory factory = Models.getModelFactory();
        VolatileEmitter emitter = new VolatileEmitter();
        com.asakusafw.dmdl.java.Configuration conf = new com.asakusafw.dmdl.java.Configuration(
                factory,
                source,
                Models.toName(factory, "com.example"),
View Full Code Here

        for (PropertyDeclaration property : model.getDeclaredProperties()) {
            if (isTextType(property) == false) {
                continue;
            }
            if (projective) {
                ModelFactory f = context.getModelFactory();
                results.add(makeInterfaceMethod(f, createStringGetter(context, property)));
                results.add(makeInterfaceMethod(f, createStringSetter(context, property)));
            } else {
                results.add(createStringGetter(context, property));
                results.add(createStringSetter(context, property));
View Full Code Here

TOP

Related Classes of com.asakusafw.utils.java.model.syntax.ModelFactory

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.