Package com.asakusafw.utils.java.model.util

Examples of com.asakusafw.utils.java.model.util.TypeBuilder


    private Expression createLookup(LineEndProcessor.Context context, ModelFactory f) {
        assert context != null;
        assert f != null;
        Expression lookup = context.createLocalVariable(
                context.simplify(new TypeBuilder(f, Models.toType(f, List.class))
                    .parameterize(Models.toType(f, resource.getMasterDataClass().getType()))
                    .toType()),
                new ExpressionBuilder(f, context.getResource(resource))
                    .method("find", context.getInput())
                    .toExpression());
View Full Code Here


                        new ExpressionBuilder(factory, factory.newThis())
                            .field(RESOLVER_FIELD_NAME)
                            .method("getElement")
                            .method("override", factory.newConditionalExpression(
                                    optimize,
                                    new TypeBuilder(factory, util.t(Inline.class))
                                        .field(Inline.FORCE_AGGREGATE.name())
                                        .toExpression(),
                                    new TypeBuilder(factory, util.t(Inline.class))
                                        .field(Inline.KEEP_SEGREGATED.name())
                                        .toExpression()))
                            .toStatement(),
                        new ExpressionBuilder(factory, factory.newThis())
                            .toReturnStatement(),
View Full Code Here

            List<FormalParameterDeclaration> parameters,
            NameGenerator names) {
        assert parameters != null;
        List<Statement> statements = Lists.create();
        SimpleName builderName = names.create("builder");
        statements.add(new TypeBuilder(factory, util.t(FlowPartDescription.Builder.class))
            .newObject(factory.newClassLiteral(util.t(flowClass.getElement())))
            .toLocalVariableDeclaration(util.t(FlowPartDescription.Builder.class),
                    builderName));

        Expression[] arguments = new Expression[
                flowClass.getInputPorts().size()
                + flowClass.getOutputPorts().size()
                + flowClass.getParameters().size()
                ];
        for (OperatorPortDeclaration var : flowClass.getInputPorts()) {
            SimpleName name = names.create(var.getName());
            statements.add(new ExpressionBuilder(factory, builderName)
                .method("addInput",
                        util.v(var.getName()),
                        factory.newSimpleName(var.getType().getReference()))
                .toLocalVariableDeclaration(
                        util.toInType(var.getType().getRepresentation()),
                        name));
            arguments[var.getParameterPosition()] = name;
        }
        for (OperatorPortDeclaration var : flowClass.getOutputPorts()) {
            SimpleName name = names.create(var.getName());
            Expression type = toExpression(var);
            assert type != null;
            statements.add(new ExpressionBuilder(factory, builderName)
                .method("addOutput", util.v(var.getName()), type)
                .toLocalVariableDeclaration(
                        util.toOutType(var.getType().getRepresentation()),
                        name));
            arguments[var.getParameterPosition()] = name;
        }
        for (OperatorPortDeclaration var : flowClass.getParameters()) {
            Expression type = toExpression(var);
            SimpleName name = factory.newSimpleName(var.getName());
            statements.add(new ExpressionBuilder(factory, builderName)
                .method("addParameter",
                    util.v(var.getName()),
                    type,
                    name)
                .toStatement());
            arguments[var.getParameterPosition()] = name;
        }
        SimpleName descName = names.create("desc");
        statements.add(new TypeBuilder(factory, getType(util.t(flowClass.getElement())))
            .newObject(arguments)
            .toLocalVariableDeclaration(util.t(FlowDescription.class), descName));

        Expression resolver = new ExpressionBuilder(factory, factory.newThis())
            .field(RESOLVER_FIELD_NAME)
View Full Code Here

                factory.newSimpleName("create"),
                parameters,
                0,
                Collections.<Type>emptyList(),
                factory.newBlock(
                        new TypeBuilder(factory, type)
                            .newObject(arguments)
                            .toReturnStatement()));
    }
View Full Code Here

        assert objectType.getModelKind() != ModelKind.PARAMETERIZED_TYPE;
        Type type;
        if (flowClass.getElement().getTypeParameters().isEmpty()) {
            type = objectType;
        } else {
            type = new TypeBuilder(factory, objectType)
                .parameterize(util.toTypeVariables(flowClass.getElement()))
                .toType();
        }
        return type;
    }
View Full Code Here

                    new AttributeBuilder(factory)
                        .Public()
                        .toAttributes(),
                    name,
                    Collections.<TypeParameterDeclaration>emptyList(),
                    new TypeBuilder(factory, importer.toType(SlotDistributor.class))
                        .parameterize(importer.toType(slot.getValueClass().getType()))
                        .toType(),
                    Collections.<Type>emptyList(),
                    Collections.singletonList(createSlotSpec()));
        }
View Full Code Here

                new AttributeBuilder(factory)
                    .Private()
                    .toAttributes(),
                fieldType,
                fieldName,
                new TypeBuilder(factory, fieldType)
                    .newObject()
                    .toExpression()));
        return factory.newFieldAccessExpression(factory.newThis(), fieldName);
    }
View Full Code Here

        for (Map.Entry<ResourceFragment, SimpleName> entry : resources.entrySet()) {
            ResourceFragment resource = entry.getKey();
            SimpleName field = entry.getValue();
            results.add(new ExpressionBuilder(factory, factory.newThis())
                .field(field)
                .assignFrom(new TypeBuilder(factory, importer.toType(resource.getCompiled().getQualifiedName()))
                    .newObject()
                    .toExpression())
                .toStatement());
            results.add(new ExpressionBuilder(factory, factory.newThis())
                .field(field)
View Full Code Here

    private List<Statement> setupStageOutputs(Expression context) {
        assert context != null;
        List<Statement> results = Lists.create();
        results.add(new ExpressionBuilder(factory, factory.newThis())
            .field(stageOutputs)
            .assignFrom(new TypeBuilder(factory, importer.toType(StageOutputDriver.class))
                .newObject(context)
                .toExpression())
            .toStatement());
        return results;
    }
View Full Code Here

        Type type = importer.resolve(factory.newNamedType(value.getCompiled().getQualifiedName()));
        List<Expression> arguments = resolveArguments(node, value);
        if (lines.containsKey(input)) {
            return new ExpressionBuilder(factory, factory.newThis())
                .field(node.getName())
                .assignFrom(new TypeBuilder(factory, type)
                    .newObject(arguments)
                    .toExpression())
                .toStatement();
        } else {
            return factory.newLocalVariableDeclaration(
                    new AttributeBuilder(factory)
                        .Final()
                        .toAttributes(),
                    type,
                    Collections.singletonList(factory.newVariableDeclarator(
                            node.getName(),
                            new TypeBuilder(factory, type)
                                .newObject(arguments)
                                .toExpression())));
        }
    }
View Full Code Here

TOP

Related Classes of com.asakusafw.utils.java.model.util.TypeBuilder

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.