001// SPDX-License-Identifier: GPL-3.0-or-later
002
003/**
004 * 
005 */
006package es.uvigo.esei.sing.textproc.abstracttppstep;
007
008import java.util.Collections;
009import java.util.HashSet;
010import java.util.Set;
011
012import es.uvigo.esei.sing.textproc.abstracttppstep.xml.definition.EndpointProcessingStepParameter;
013import es.uvigo.esei.sing.textproc.step.ProcessingStepService;
014import es.uvigo.esei.sing.textproc.step.xml.definition.AbstractProcessingStepParameter;
015
016/**
017 * Implements {@link #getAdditionalParameters()} so that additional parameters
018 * common to every Text Processing Python processing step are returned without
019 * involvement of the subclass.
020 * <p>
021 * Extending this class is the mandatory way to implement a
022 * {@link ProcessingStepService} for concrete processing steps.
023 *
024 * @author Alejandro González García
025 */
026public abstract class AbstractTppProcessingStepService implements ProcessingStepService {
027        @Override
028        public final Set<Class<? extends AbstractProcessingStepParameter>> getAdditionalParameters() {
029                final Set<Class<? extends AbstractProcessingStepParameter>> completeSet = new HashSet<>(
030                        getAdditionalParticularParameters()
031                );
032
033                completeSet.addAll(
034                        Set.of(
035                                EndpointProcessingStepParameter.class
036                        )
037                );
038
039                return Collections.unmodifiableSet(completeSet);
040        }
041
042        /**
043         * This method serves the same purpose and has the same preconditions and
044         * postconditions than {@link #getAdditionalParameters()}, but it is named
045         * different to avoid signature clashes and allow transparent common parameter
046         * injection to concrete services.
047         *
048         * @return The value of {@link #getAdditionalParameters()}.
049         * @see ProcessingStepService#getAdditionalParameters()
050         */
051        protected abstract Set<Class<? extends AbstractProcessingStepParameter>> getAdditionalParticularParameters();
052}