PakhomovAlexander commented on code in PR #943: URL: https://github.com/apache/ignite-3/pull/943#discussion_r923402303
########## modules/cli/src/main/java/org/apache/ignite/cli/core/flow/builder/FlowBuilderImpl.java: ########## @@ -0,0 +1,126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.cli.core.flow.builder; + +import java.io.PrintWriter; +import java.util.List; +import java.util.function.Function; +import java.util.function.Predicate; +import org.apache.ignite.cli.commands.decorators.DefaultDecoratorRegistry; +import org.apache.ignite.cli.core.decorator.DecoratorRegistry; +import org.apache.ignite.cli.core.exception.ExceptionHandler; +import org.apache.ignite.cli.core.exception.ExceptionHandlers; +import org.apache.ignite.cli.core.exception.ExceptionWriter; +import org.apache.ignite.cli.core.exception.handler.DefaultExceptionHandlers; +import org.apache.ignite.cli.core.flow.Flow; +import org.apache.ignite.cli.core.flow.FlowInterruptException; +import org.apache.ignite.cli.core.flow.Flowable; +import org.apache.ignite.cli.core.flow.question.QuestionAnswer; +import org.apache.ignite.cli.core.flow.question.QuestionAskerFactory; + +/** + * Implementation of {@link FlowBuilder}. + * + * @param <I> flow input type. + * @param <O> flow output type. + */ +public class FlowBuilderImpl<I, O> implements FlowBuilder<I, O> { + private final Flow<I, O> flow; + private final ExceptionHandlers exceptionHandlers = new DefaultExceptionHandlers(); + private final DecoratorRegistry decoratorRegistry = new DefaultDecoratorRegistry(); + + public FlowBuilderImpl(Flow<I, O> flow) { + this(flow, new DefaultExceptionHandlers(), new DefaultDecoratorRegistry()); + } + + /** + * Constructor. + * + * @param flow flow instance. + * @param exceptionHandlers exception handlers. + * @param decoratorRegistry decorator registry. + */ + public FlowBuilderImpl(Flow<I, O> flow, ExceptionHandlers exceptionHandlers, DecoratorRegistry decoratorRegistry) { + this.flow = flow; + this.exceptionHandlers.addExceptionHandlers(exceptionHandlers); + this.decoratorRegistry.addAll(decoratorRegistry); + } + + @Override + public <OT> FlowBuilder<I, OT> appendFlow(Flow<O, OT> flow) { Review Comment: I think `then` here is more consistent name. Looking at the next method it is logical to have `then` and `ifThen` instead of `appendFlow` and `ifThen`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
