001/**
002 * Copyright (C) 2006-2025 Talend Inc. - www.talend.com
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.talend.sdk.component.design.extension.flows;
017
018import java.util.Collection;
019
020import org.talend.sdk.component.runtime.base.Lifecycle;
021import org.talend.sdk.component.runtime.manager.ComponentFamilyMeta.BaseMeta;
022import org.talend.sdk.component.runtime.manager.ComponentFamilyMeta.DriverRunnerMeta;
023import org.talend.sdk.component.runtime.manager.ComponentFamilyMeta.PartitionMapperMeta;
024import org.talend.sdk.component.runtime.manager.ComponentFamilyMeta.ProcessorMeta;
025
026/**
027 * Strategy creates component flows according component type (either
028 * {@link ProcessorMeta} or {@link PartitionMapperMeta})
029 */
030public interface FlowsFactory {
031
032    /**
033     * Creates appropriate factory according {@link BaseMeta} type (either
034     * {@link ProcessorMeta} or {@link PartitionMapperMeta})
035     * 
036     * @param meta the meta instance to use as reference to find the right factory.
037     * @return the factory to use to create a flow for this meta.
038     */
039    static FlowsFactory get(final BaseMeta<? extends Lifecycle> meta) {
040        if (meta == null) {
041            throw new IllegalArgumentException("meta should not be null");
042        }
043        if (PartitionMapperMeta.class.isInstance(meta)) {
044            return new PartitionMapperFlowsFactory();
045        }
046        if (ProcessorMeta.class.isInstance(meta)) {
047            return new ProcessorFlowsFactory(meta.getType());
048        }
049        if (DriverRunnerMeta.class.isInstance(meta)) {
050            return new DriverRunnerFlowsFactory();
051        }
052        throw new IllegalArgumentException("unknown meta type " + meta.getClass().getName());
053    }
054
055    /**
056     * Returns a {@link Collection} of input flows names of a Component
057     * 
058     * @return input flows names collection
059     */
060    Collection<String> getInputFlows();
061
062    /**
063     * Returns a {@link Collection} of output flows names of a Component
064     * 
065     * @return output flows names collection
066     */
067    Collection<String> getOutputFlows();
068}