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 public class JobOutput {
13
14
15
16 private final Job job;
17
18
19
20 private final int index;
21
22
23
24 private final String name;
25
26
27
28 private final int length;
29
30
31
32 private final Optional<String> step;
33
34
35
36 private final Optional<String> procedureStep;
37
38
39
40 private final Optional<String> outputClass;
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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
70
71
72
73 @SuppressJacocoGenerated(justification = "private method, used for toString only")
74 private String getJobId() {
75 return getJob().getId();
76 }
77
78
79
80
81
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
107
108
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
119
120
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
131
132
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
143
144
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
155
156
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
167
168
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
179
180
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 }