001/*-
002 * #%L
003 * HAPI FHIR JPA Server - Batch2 Task Processor
004 * %%
005 * Copyright (C) 2014 - 2024 Smile CDR, Inc.
006 * %%
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 * You may obtain a copy of the License at
010 *
011 *      http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 * #L%
019 */
020package ca.uhn.fhir.batch2.model;
021
022import ca.uhn.fhir.batch2.api.IJobStepWorker;
023import ca.uhn.fhir.model.api.IModelJson;
024import jakarta.annotation.Nonnull;
025import org.apache.commons.lang3.Validate;
026
027import static ca.uhn.fhir.batch2.model.JobDefinition.ID_MAX_LENGTH;
028
029public class JobDefinitionStep<PT extends IModelJson, IT extends IModelJson, OT extends IModelJson> {
030
031        private final String myStepId;
032        private final String myStepDescription;
033        protected final IJobStepWorker<PT, IT, OT> myJobStepWorker;
034        private final Class<IT> myInputType;
035
036        private final Class<OT> myOutputType;
037
038        public JobDefinitionStep(
039                        @Nonnull String theStepId,
040                        @Nonnull String theStepDescription,
041                        @Nonnull IJobStepWorker<PT, IT, OT> theJobStepWorker,
042                        @Nonnull Class<IT> theInputType,
043                        @Nonnull Class<OT> theOutputType) {
044                Validate.notBlank(theStepId, "No step ID specified");
045                Validate.isTrue(theStepId.length() <= ID_MAX_LENGTH, "Maximum ID length is %d", ID_MAX_LENGTH);
046                Validate.notBlank(theStepDescription);
047                Validate.notNull(theInputType);
048                myStepId = theStepId;
049                myStepDescription = theStepDescription;
050                myJobStepWorker = theJobStepWorker;
051                myInputType = theInputType;
052                myOutputType = theOutputType;
053        }
054
055        public String getStepId() {
056                return myStepId;
057        }
058
059        public String getStepDescription() {
060                return myStepDescription;
061        }
062
063        public IJobStepWorker<PT, IT, OT> getJobStepWorker() {
064                return myJobStepWorker;
065        }
066
067        public Class<IT> getInputType() {
068                return myInputType;
069        }
070
071        public Class<OT> getOutputType() {
072                return myOutputType;
073        }
074
075        public boolean isReductionStep() {
076                return false;
077        }
078}