-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLookupWordsTO.java
More file actions
133 lines (105 loc) · 3.32 KB
/
LookupWordsTO.java
File metadata and controls
133 lines (105 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package scanning;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.ValidationException;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import javax.validation.constraints.NotNull;
public class LookupWordsTO {
private static final Logger logger = LoggerFactory.getLogger(LookupWordsTO.class);
@NotNull(message = "Test-Data (JSON) field cannot be null: zielKategorie")
String zielKategorie;
@NotNull(message = "Test-Data (JSON) field cannot be null: zielName")
String zielName;
@NotNull(message = "Test-Data (JSON) field cannot be null: w1")
String w1;
@NotNull(message = "Test-Data (JSON) field cannot be null: w2")
String w2;
@NotNull(message = "Test-Data (JSON) field cannot be null: w3")
String w3;
@NotNull(message = "Test-Data (JSON) field cannot be null: w4")
String w4;
public String getzielKategorie() {
return zielKategorie;
}
public String getzielName() {
return zielName;
}
public String getW1() {
return w1;
}
public String getW2() {
return w2;
}
public String getW3() {
return w3;
}
public String getW4() {
return w4;
}
public void setZielKategorie(String zielKategorie) {
this.zielKategorie = zielKategorie;
}
public void setZielName(String zielName) {
this.zielName = zielName;
}
public void setW1(String w1) {
this.w1 = w1;
}
public void setW2(String w2) {
this.w2 = w2;
}
public void setW3(String w3) {
this.w3 = w3;
}
public void setW4(String w4) {
this.w4 = w4;
}
public List<String> getWordList(){
List<String> wordList = new ArrayList<>();
if (w1 != null)
if (w1.length() >1)
wordList.add(w1);
if (w2 != null)
if (w2.length() >1)
wordList.add(w2);
if (w3 != null)
if (w3.length() >1)
wordList.add(w3);
if (w4 != null)
if (w4.length() >1)
wordList.add(w4);
return wordList;
}
@Override
public String toString() {
return "zielKategorie:" + zielKategorie
+" | zielName:" + zielName
+" | w1:" + w1
+" | w2:" + w2
+" | w3:" + w3
+" | w4:" + w4
;
}
public void validate(){
// logger.info("");
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
Set<ConstraintViolation<LookupWordsTO>> violations = validator.validate(this);
if (violations.size() > 0) {
StringBuilder sb = new StringBuilder();
sb.append(System.getProperty("line.separator"));
for (ConstraintViolation<LookupWordsTO> violation : violations) {
sb.append(violation.getMessage());
sb.append(System.getProperty("line.separator"));
}
logger.debug(sb.toString());
throw new ValidationException("ERROR on test data: " + String.valueOf(sb));
}
}
}