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