View Javadoc
1   // Generated by delombok at Fri Sep 19 22:55:48 UTC 2025
2   package de.larssh.jes;
3   
4   import java.util.Optional;
5   import de.larssh.utils.annotations.SuppressJacocoGenerated;
6   import de.larssh.utils.text.Strings;
7   import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
8   
9   /**
10   * Value object containing a job outputs details.
11   */
12  public class JobOutput {
13  	/**
14  	 * Corresponding {@link Job}
15  	 */
16  	private final Job job;
17  	/**
18  	 * The job outputs index inside the jobs list of outputs (starting at 1)
19  	 */
20  	private final int index;
21  	/**
22  	 * The job outputs data division name
23  	 */
24  	private final String name;
25  	/**
26  	 * The job outputs content length
27  	 */
28  	private final int length;
29  	/**
30  	 * The job outputs step name
31  	 */
32  	private final Optional<String> step;
33  	/**
34  	 * The job outputs procedure step name
35  	 */
36  	private final Optional<String> procedureStep;
37  	/**
38  	 * The job outputs class
39  	 */
40  	private final Optional<String> outputClass;
41  
42  	/**
43  	 * This constructor creates a {@link JobOutput}. String parameters are trimmed
44  	 * and converted to upper case.
45  	 *
46  	 * @param job           the corresponding job
47  	 * @param index         the job outputs index inside the jobs list of outputs
48  	 *                      (starting at 1)
49  	 * @param name          the job outputs data division name
50  	 * @param length        the job outputs content length
51  	 * @param step          the job outputs step name
52  	 * @param procedureStep the job outputs procedure step name
53  	 * @param outputClass   the output class
54  	 * @throws JobFieldInconsistentException on inconsistent field value
55  	 */
56  	@SuppressFBWarnings(value = "CT_CONSTRUCTOR_THROW", justification = "Fields are initialized prior throwing exceptions")
57  	protected JobOutput(final Job job, final int index, final String name, final int length, final Optional<String> step, final Optional<String> procedureStep, final Optional<String> outputClass) {
58  		this.job = job;
59  		this.index = index;
60  		this.name = Strings.toUpperCaseNeutral(name.trim());
61  		this.length = length;
62  		this.step = step.map(String::trim).map(Strings::toUpperCaseNeutral);
63  		this.procedureStep = procedureStep.map(String::trim).map(Strings::toUpperCaseNeutral);
64  		this.outputClass = outputClass.map(String::trim).map(Strings::toUpperCaseNeutral);
65  		validate();
66  	}
67  
68  	/**
69  	 * Corresponding {@link Job}s ID for {@link lombok.ToString.Include}
70  	 *
71  	 * @return the jobs ID
72  	 */
73  	@SuppressJacocoGenerated(justification = "private method, used for toString only")
74  	private String getJobId() {
75  		return getJob().getId();
76  	}
77  
78  	/**
79  	 * Validates fields to be set in a consistent way.
80  	 *
81  	 * @throws JobFieldInconsistentException on inconsistent field value
82  	 */
83  	@SuppressWarnings("PMD.CyclomaticComplexity")
84  	private void validate() {
85  		if (index < 1) {
86  			throw new JobFieldInconsistentException("Index must not be less than one.");
87  		}
88  		if (name.isEmpty()) {
89  			throw new JobFieldInconsistentException("Name must not be empty.");
90  		}
91  		if (length < 0) {
92  			throw new JobFieldInconsistentException("Length must not be less than zero.");
93  		}
94  		if (step.filter(String::isEmpty).isPresent()) {
95  			throw new JobFieldInconsistentException("Step must not be empty if present.");
96  		}
97  		if (procedureStep.filter(String::isEmpty).isPresent()) {
98  			throw new JobFieldInconsistentException("Procedure Step must not be empty if present.");
99  		}
100 		if (outputClass.filter(String::isEmpty).isPresent()) {
101 			throw new JobFieldInconsistentException("Output class must not be empty if present.");
102 		}
103 	}
104 
105 	/**
106 	 * Corresponding {@link Job}
107 	 *
108 	 * @return job
109 	 */
110 	@java.lang.SuppressWarnings("all")
111 	@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(justification = "generated code")
112 	@lombok.Generated
113 	public Job getJob() {
114 		return this.job;
115 	}
116 
117 	/**
118 	 * The job outputs index inside the jobs list of outputs (starting at 1)
119 	 *
120 	 * @return job output index
121 	 */
122 	@java.lang.SuppressWarnings("all")
123 	@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(justification = "generated code")
124 	@lombok.Generated
125 	public int getIndex() {
126 		return this.index;
127 	}
128 
129 	/**
130 	 * The job outputs data division name
131 	 *
132 	 * @return job output name
133 	 */
134 	@java.lang.SuppressWarnings("all")
135 	@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(justification = "generated code")
136 	@lombok.Generated
137 	public String getName() {
138 		return this.name;
139 	}
140 
141 	/**
142 	 * The job outputs content length
143 	 *
144 	 * @return job output length
145 	 */
146 	@java.lang.SuppressWarnings("all")
147 	@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(justification = "generated code")
148 	@lombok.Generated
149 	public int getLength() {
150 		return this.length;
151 	}
152 
153 	/**
154 	 * The job outputs step name
155 	 *
156 	 * @return step
157 	 */
158 	@java.lang.SuppressWarnings("all")
159 	@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(justification = "generated code")
160 	@lombok.Generated
161 	public Optional<String> getStep() {
162 		return this.step;
163 	}
164 
165 	/**
166 	 * The job outputs procedure step name
167 	 *
168 	 * @return procedure step
169 	 */
170 	@java.lang.SuppressWarnings("all")
171 	@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(justification = "generated code")
172 	@lombok.Generated
173 	public Optional<String> getProcedureStep() {
174 		return this.procedureStep;
175 	}
176 
177 	/**
178 	 * The job outputs class
179 	 *
180 	 * @return output class
181 	 */
182 	@java.lang.SuppressWarnings("all")
183 	@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(justification = "generated code")
184 	@lombok.Generated
185 	public Optional<String> getOutputClass() {
186 		return this.outputClass;
187 	}
188 
189 	@edu.umd.cs.findbugs.annotations.NonNull
190 	@java.lang.Override
191 	@java.lang.SuppressWarnings("all")
192 	@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(justification = "generated code")
193 	@lombok.Generated
194 	public java.lang.String toString() {
195 		return "JobOutput(job.id=" + this.getJobId() + ", index=" + this.getIndex() + ", name=" + this.getName() + ", length=" + this.getLength() + ", step=" + this.getStep() + ", procedureStep=" + this.getProcedureStep() + ", outputClass=" + this.getOutputClass() + ")";
196 	}
197 
198 	@java.lang.Override
199 	@java.lang.SuppressWarnings("all")
200 	@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(justification = "generated code")
201 	@lombok.Generated
202 	public boolean equals(@edu.umd.cs.findbugs.annotations.Nullable final java.lang.Object o) {
203 		if (o == this) return true;
204 		if (!(o instanceof JobOutput)) return false;
205 		final JobOutput other = (JobOutput) o;
206 		if (!other.canEqual((java.lang.Object) this)) return false;
207 		if (this.getIndex() != other.getIndex()) return false;
208 		final java.lang.Object this$job = this.getJob();
209 		final java.lang.Object other$job = other.getJob();
210 		if (this$job == null ? other$job != null : !this$job.equals(other$job)) return false;
211 		return true;
212 	}
213 
214 	@java.lang.SuppressWarnings("all")
215 	@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(justification = "generated code")
216 	@lombok.Generated
217 	protected boolean canEqual(@edu.umd.cs.findbugs.annotations.Nullable final java.lang.Object other) {
218 		return other instanceof JobOutput;
219 	}
220 
221 	@java.lang.Override
222 	@java.lang.SuppressWarnings("all")
223 	@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(justification = "generated code")
224 	@lombok.Generated
225 	public int hashCode() {
226 		final int PRIME = 59;
227 		int result = 1;
228 		result = result * PRIME + this.getIndex();
229 		final java.lang.Object $job = this.getJob();
230 		result = result * PRIME + ($job == null ? 43 : $job.hashCode());
231 		return result;
232 	}
233 }