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

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


        OperatorDescription desc = context.getOperatorDescription();
        FlowElementPortDescription master = desc.getInputPorts().get(0);

        Expression hasMaster = context.createField(boolean.class, "sawMaster");
        DataObjectMirror masterCache = context.createModelCache(master.getDataType());
        context.addBegin(new ExpressionBuilder(f, hasMaster)
            .assignFrom(Models.toLiteral(f, false))
            .toStatement());
        context.addProcess(master, f.newIfStatement(
                new ExpressionBuilder(f, hasMaster)
                    .apply(InfixOperator.EQUALS, Models.toLiteral(f, false))
                    .toExpression(),
                f.newBlock(new Statement[] {
                        masterCache.createSet(context.getProcessInput(master)),
                        new ExpressionBuilder(f, hasMaster)
                            .assignFrom(Models.toLiteral(f, true))
                            .toStatement()
                }),
                null));
View Full Code Here


        }

        context.addProcess(tx, list.createEnd());
        Expression impl = context.createImplementation();
        SimpleName selected = context.createName("selected");
        context.addProcess(tx, new ExpressionBuilder(f, impl)
            .method(selector.getName(), arguments)
            .toLocalVariableDeclaration(
                    context.convert(master.getDataType()),
                    selected));

        context.addEnd(list.createShrink());

        this.hasMasterExpresion = new ExpressionBuilder(f, selected)
            .apply(InfixOperator.NOT_EQUALS, Models.toNullLiteral(f))
            .toExpression();
        this.getMasterExpression = selected;
        this.getCheckedMasterExpression = selected;
    }
View Full Code Here

        assert context != null;
        ModelFactory f = context.getModelFactory();

        Expression lookup = createLookup(context, f);

        this.hasMasterExpresion = new ExpressionBuilder(f, lookup)
            .method("isEmpty")
            .apply(InfixOperator.EQUALS, Models.toLiteral(f, false))
            .toExpression();
        this.getMasterExpression = new ExpressionBuilder(f, lookup)
            .method("get", Models.toLiteral(f, 0))
            .toExpression();
        this.getCheckedMasterExpression = f.newConditionalExpression(
                new ExpressionBuilder(f, lookup)
                    .method("isEmpty")
                    .toExpression(),
                Models.toNullLiteral(f),
                getMasterExpression);
    }
View Full Code Here

        if (selector.getParameterTypes().size() <= arguments.size()) {
            arguments = arguments.subList(0, selector.getParameterTypes().size());
        }
        Expression impl = context.createImplementation();
        context.add(f.newIfStatement(
                new ExpressionBuilder(f, lookup)
                    .apply(InfixOperator.NOT_EQUALS, Models.toNullLiteral(f))
                    .toExpression(),
                f.newBlock(new ExpressionBuilder(f, selected)
                    .assignFrom(new ExpressionBuilder(f, impl)
                        .method(selector.getName(), arguments)
                        .toExpression())
                    .toStatement())));

        this.hasMasterExpresion = new ExpressionBuilder(f, selected)
            .apply(InfixOperator.NOT_EQUALS, Models.toNullLiteral(f))
            .toExpression();
        this.getMasterExpression = selected;
        this.getCheckedMasterExpression = selected;
    }
View Full Code Here

         * {@link ListBuffer}の開始処理を行う文を返す。
         * @return 生成した文
         * @see ListBuffer#begin()
         */
        public Statement createBegin() {
            return new ExpressionBuilder(factory, object)
                .method(BEGIN)
                .toStatement();
        }
View Full Code Here

        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());
        return lookup;
    }
View Full Code Here

         * @see ListBuffer#isExpandRequired()
         */
        public Statement createAdvance(Expression value) {
            Precondition.checkMustNotBeNull(value, "value"); //$NON-NLS-1$
            List<Statement> thenBlock = Arrays.asList(new Statement[] {
                    new ExpressionBuilder(factory, object)
                        .method(EXPAND, dataClass.createNewInstance(elementType))
                        .toStatement(),
                    dataClass.assign(
                            new ExpressionBuilder(factory, object)
                                .method(ADVANCE)
                                .toExpression(),
                            value),
            });
            List<Statement> elseBlock = Arrays.asList(new Statement[] {
                    dataClass.assign(
                            new ExpressionBuilder(factory, object)
                                .method(ADVANCE)
                                .toExpression(),
                            value),
            });
            return factory.newIfStatement(
                    new ExpressionBuilder(factory, object)
                        .method(IS_EXPAND_REQUIRED)
                        .toExpression(),
                    factory.newBlock(thenBlock),
                    factory.newBlock(elseBlock));
        }
View Full Code Here

            return results;
        }

        private MethodDeclaration createOutputName() {
            List<Statement> statements = Lists.create();
            statements.add(new ExpressionBuilder(factory, Models.toLiteral(factory, slot.getSource().getOutputName()))
                .toReturnStatement());
            return factory.newMethodDeclaration(
                    null,
                    new AttributeBuilder(factory)
                        .annotation(importer.toType(Override.class))
View Full Code Here

         * {@link ListBuffer}の更新終了処理を行う文を返す。
         * @return 生成した文
         * @see ListBuffer#end()
         */
        public Statement createEnd() {
            return new ExpressionBuilder(factory, object)
                .method(END)
                .toStatement();
        }
View Full Code Here

         * {@link ListBuffer}の参照終了処理を行う文を返す。
         * @return 生成した文
         * @see ListBuffer#end()
         */
        public Statement createShrink() {
            return new ExpressionBuilder(factory, object)
                .method(SHRINK)
                .toStatement();
        }
View Full Code Here

TOP

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

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.