Examples of TypeBuilder


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

                    .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(
View Full Code Here

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

                    .toExpression());

        Level level = context.getOperatorDescription().getAttribute(Logging.Level.class);
        switch (level == null ? Level.getDefault() : level) {
        case WARN:
            context.add(new TypeBuilder(f, context.convert(Report.class))
                .method("warn", result)
                .toStatement());
            break;
        case ERROR:
            context.add(new TypeBuilder(f, context.convert(Report.class))
                .method("error", result)
                .toStatement());
            break;
        default:
            context.add(new TypeBuilder(f, context.convert(Report.class))
                .method("info", result)
                .toStatement());
            break;
        }
        context.setOutput(input);
View Full Code Here

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

        private MethodDeclaration createStageInputsMethod() {
            SimpleName list = factory.newSimpleName("results");
            SimpleName attributes = factory.newSimpleName("attributes");

            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)
View Full Code Here

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

        }

        private MethodDeclaration createStageOutputsMethod() {
            SimpleName list = factory.newSimpleName("results");
            List<Statement> statements = Lists.create();
            statements.add(new TypeBuilder(factory, t(ArrayList.class, t(StageOutput.class)))
                .newObject()
                .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)))
View Full Code Here

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

        }

        private TypeBodyDeclaration createStageResourcesMethod() {
            SimpleName list = factory.newSimpleName("results");
            List<Statement> statements = Lists.create();
            statements.add(new TypeBuilder(factory, t(ArrayList.class, t(StageResource.class)))
                .newObject()
                .toLocalVariableDeclaration(t(List.class, t(StageResource.class)), list));
            for (SideData sideData : stage.getSideData()) {
                for (Location location : sideData.getClusterPaths()) {
                    statements.add(new ExpressionBuilder(factory, list)
                        .method("add", new TypeBuilder(factory, t(StageResource.class))
                            .newObject(
                                    Models.toLiteral(factory, location.toPath('/')),
                                    Models.toLiteral(factory, sideData.getLocalName()))
                            .toExpression())
                        .toStatement());
View Full Code Here

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

                        .Private()
                        .Final()
                        .toAttributes(),
                    keyType,
                    keyModel,
                    new TypeBuilder(factory, keyType)
                        .newObject()
                        .toExpression());
        }
View Full Code Here

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

                        .Private()
                        .Final()
                        .toAttributes(),
                    valueType,
                    valueModel,
                    new TypeBuilder(factory, valueType)
                        .newObject()
                        .toExpression());
        }
View Full Code Here

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

                .field(valueModel)
                .method(Naming.getShuffleValueSetter(segment.getPortId()),
                        shuffleInput)
                .toStatement());

            results.add(new TypeBuilder(factory, t(ResultOutput.class))
                .method("write",
                        new ExpressionBuilder(factory, factory.newThis())
                            .field(collector)
                            .toExpression(),
                        new ExpressionBuilder(factory, factory.newThis())
View Full Code Here

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

                    .toJavadoc(),
                new AttributeBuilder(factory)
                    .Public()
                    .toAttributes(),
                name,
                importer.resolve(new TypeBuilder(factory, Models.toType(factory, JoinResource.class))
                    .parameterize(
                            resource.getMasterDataClass().getType(),
                            resource.getTransactionDataClass().getType())
                    .toType()),
                Collections.<Type>emptyList(),
View Full Code Here

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

         */
        public void addAttribute(Enum<? extends FlowElementAttribute> constant) {
            Precondition.checkMustNotBeNull(constant, "constant"); //$NON-NLS-1$
            ModelFactory f = context.environment.getFactory();
            ImportBuilder ib = context.importer;
            Expression attribute = new TypeBuilder(f, ib.toType(constant.getDeclaringClass()))
                .field(constant.name())
                .toExpression();
            addAttribute(attribute);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.