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

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


            arguments.add(context.getOutput(output).get());
        }
        for (OperatorDescription.Parameter param : desc.getParameters()) {
            arguments.add(Models.toLiteral(f, param.getValue()));
        }
        context.add(new ExpressionBuilder(f, impl)
            .method(desc.getDeclaration().getName(), arguments)
            .toStatement());
    }
View Full Code Here


        arguments.add(input);
        for (OperatorDescription.Parameter param : desc.getParameters()) {
            arguments.add(Models.toLiteral(f, param.getValue()));
        }

        context.add(new ExpressionBuilder(f, impl)
            .method(desc.getDeclaration().getName(), arguments)
            .toStatement());

        context.setOutput(input);
    }
View Full Code Here

        for (OperatorDescription.Parameter param : desc.getParameters()) {
            arguments.add(Models.toLiteral(f, param.getValue()));
        }
        Expression result = context.createLocalVariable(
                enumType,
                new ExpressionBuilder(f, impl)
                    .method(desc.getDeclaration().getName(), arguments)
                    .toExpression());
        List<Tuple2<Enum<?>, FlowElementPortDescription>> constants =
            EnumUtil.extractConstants(enumType, desc.getOutputPorts());
View Full Code Here

            List<Statement> statements = Lists.create();
            statements.add(new TypeBuilder(factory, t(ArrayList.class, t(StageInput.class)))
                .newObject()
                .toLocalVariableDeclaration(t(List.class, t(StageInput.class)), list));
            statements.add(new ExpressionBuilder(factory, Models.toNullLiteral(factory))
                .toLocalVariableDeclaration(t(Map.class, t(String.class), t(String.class)), attributes));

            for (CopyDescription slot : slots) {
                SourceInfo info = slot.getInput();
                Type mapperType = generateMapper(slot);
                Type formatClass = t(info.getFormat());
                statements.add(new ExpressionBuilder(factory, attributes)
                    .assignFrom(new TypeBuilder(factory, t(HashMap.class, t(String.class), t(String.class)))
                        .newObject()
                        .toExpression())
                    .toStatement());
                for (Map.Entry<String, String> entry : info.getAttributes().entrySet()) {
                    statements.add(new ExpressionBuilder(factory, attributes)
                        .method("put",
                                Models.toLiteral(factory, entry.getKey()),
                                Models.toLiteral(factory, entry.getValue()))
                        .toStatement());
                }
                for (Location input : info.getLocations()) {
                    statements.add(new ExpressionBuilder(factory, list)
                        .method("add", new TypeBuilder(factory, t(StageInput.class))
                            .newObject(
                                    Models.toLiteral(factory, input.toPath(PATH_SEPARATOR)),
                                    factory.newClassLiteral(formatClass),
                                    factory.newClassLiteral(mapperType),
                                    attributes)
                            .toExpression())
                        .toStatement());
                }
            }
            statements.add(new ExpressionBuilder(factory, list)
                .toReturnStatement());

            return factory.newMethodDeclaration(
                    null,
                    new AttributeBuilder(factory)
View Full Code Here

            statements.add(new TypeBuilder(factory, t(ArrayList.class, t(StageOutput.class)))
                .newObject()
                .toLocalVariableDeclaration(t(List.class, t(StageOutput.class)), list));
            for (CopyDescription slot : slots) {
                Expression valueType = factory.newClassLiteral(t(slot.getDataModel().getType()));
                statements.add(new ExpressionBuilder(factory, list)
                    .method("add", new TypeBuilder(factory, t(StageOutput.class))
                        .newObject(
                                Models.toLiteral(factory, slot.getName()),
                                factory.newClassLiteral(t(NullWritable.class)),
                                valueType,
                                factory.newClassLiteral(t(slot.getOutputFormatType())))
                        .toExpression())
                    .toStatement());
            }
            statements.add(new ExpressionBuilder(factory, list)
                .toReturnStatement());

            return factory.newMethodDeclaration(
                    null,
                    new AttributeBuilder(factory)
View Full Code Here

            List<Statement> cases = Lists.create();
            for (FlowElementInput input : fragment.getInputPorts()) {
                Segment segment = shuffle.findSegment(input);
                cases.add(factory.newSwitchCaseLabel(
                        Models.toLiteral(factory, segment.getPortId())));
                Expression model = new ExpressionBuilder(factory, value)
                    .method(Naming.getShuffleValueGetter(segment.getPortId()))
                    .toExpression();
                cases.add(new ExpressionBuilder(factory, factory.newThis())
                    .method(getMethodName(PROCESS_PREFIX, segment), model)
                    .toStatement());
                cases.add(factory.newBreakStatement());
            }
            cases.add(factory.newSwitchDefaultLabel());
            cases.add(new TypeBuilder(factory, t(AssertionError.class))
                .newObject(value)
                .toThrowStatement());

            List<Statement> statements = Lists.create();
            statements.add(factory.newSwitchStatement(
                    new ExpressionBuilder(factory, value)
                        .method(SegmentedWritable.ID_GETTER)
                        .toExpression(),
                    cases));

            return factory.newMethodDeclaration(
View Full Code Here

        for (OperatorDescription.Parameter param : desc.getParameters()) {
            arguments.add(Models.toLiteral(f, param.getValue()));
        }
        Expression result = context.createLocalVariable(
                String.class,
                new ExpressionBuilder(f, impl)
                    .method(desc.getDeclaration().getName(), arguments)
                    .toExpression());

        Level level = context.getOperatorDescription().getAttribute(Logging.Level.class);
        switch (level == null ? Level.getDefault() : level) {
View Full Code Here

         * @throws IllegalArgumentException 引数に{@code null}が指定された場合
         */
        public Expression createLocalVariable(Type type, Expression initializer) {
            Precondition.checkMustNotBeNull(type, "type"); //$NON-NLS-1$
            SimpleName name = names.create("v");
            add(new ExpressionBuilder(factory, initializer)
                .toLocalVariableDeclaration(importer.resolve(type), name));
            return name;
        }
View Full Code Here

            List<Statement> statements = Lists.create();
            statements.add(new TypeBuilder(factory, t(ArrayList.class, t(StageInput.class)))
                .newObject()
                .toLocalVariableDeclaration(t(List.class, t(StageInput.class)), list));
            statements.add(new ExpressionBuilder(factory, Models.toNullLiteral(factory))
                .toLocalVariableDeclaration(t(Map.class, t(String.class), t(String.class)), attributes));

            for (Process process : stage.getProcesses()) {
                Expression mapperType = dotClass(process.getMapperTypeName());
                for (Source source : process.getResolvedSources()) {
                    SourceInfo info = source.getInputInfo();
                    Class<?> inputFormatType = info.getFormat();
                    statements.add(new ExpressionBuilder(factory, attributes)
                        .assignFrom(new TypeBuilder(factory, t(HashMap.class, t(String.class), t(String.class)))
                            .newObject()
                            .toExpression())
                        .toStatement());
                    for (Map.Entry<String, String> entry : info.getAttributes().entrySet()) {
                        statements.add(new ExpressionBuilder(factory, attributes)
                            .method("put",
                                    Models.toLiteral(factory, entry.getKey()),
                                    Models.toLiteral(factory, entry.getValue()))
                            .toStatement());
                    }
                    for (Location location : info.getLocations()) {
                        statements.add(new ExpressionBuilder(factory, list)
                            .method("add", new TypeBuilder(factory, t(StageInput.class))
                                .newObject(
                                        Models.toLiteral(factory, location.toPath('/')),
                                        factory.newClassLiteral(t(inputFormatType)),
                                        mapperType,
                                        attributes)
                                .toExpression())
                            .toStatement());
                    }
                }
            }
            statements.add(new ExpressionBuilder(factory, list)
                .toReturnStatement());

            return factory.newMethodDeclaration(
                    null,
                    new AttributeBuilder(factory)
View Full Code Here

                .toLocalVariableDeclaration(t(List.class, t(StageOutput.class)), list));
            for (Delivery process : stage.getDeliveries()) {
                Expression valueType = factory.newClassLiteral(t(process.getDataType()));
                Class<?> outputFormatType = process.getOutputFormatType();
                for (Location location : process.getInputInfo().getLocations()) {
                    statements.add(new ExpressionBuilder(factory, list)
                        .method("add", new TypeBuilder(factory, t(StageOutput.class))
                            .newObject(
                                    Models.toLiteral(factory, location.getName()),
                                    factory.newClassLiteral(t(NullWritable.class)),
                                    valueType,
                                    factory.newClassLiteral(t(outputFormatType)))
                            .toExpression())
                        .toStatement());
                }
            }
            statements.add(new ExpressionBuilder(factory, list)
                .toReturnStatement());

            return factory.newMethodDeclaration(
                    null,
                    new AttributeBuilder(factory)
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.