1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.datadictionary.validation.result;
17
18 import org.kuali.rice.krad.datadictionary.validation.AttributeValueReader;
19 import org.kuali.rice.krad.datadictionary.validation.capability.Constrainable;
20 import org.kuali.rice.krad.datadictionary.validation.constraint.Constraint;
21 import org.kuali.rice.krad.datadictionary.validation.processor.ConstraintProcessor;
22
23 import java.util.Arrays;
24 import java.util.Collections;
25 import java.util.List;
26
27
28
29
30
31
32
33 public class ProcessorResult {
34
35 private final transient List<Constraint> constraints;
36 private final transient Constrainable definition;
37 private final transient AttributeValueReader attributeValueReader;
38
39 private final List<ConstraintValidationResult> constraintValidationResults;
40
41
42
43
44
45
46 public ProcessorResult(ConstraintValidationResult constraintValidationResult) {
47 this(constraintValidationResult, null, null);
48 }
49
50
51
52
53
54
55
56
57
58
59 public ProcessorResult(ConstraintValidationResult constraintValidationResult, Constrainable definition,
60 AttributeValueReader attributeValueReader, Constraint... constraints) {
61 this.constraintValidationResults = Collections.singletonList(constraintValidationResult);
62 this.definition = definition;
63 this.attributeValueReader = attributeValueReader;
64 this.constraints = Arrays.asList(constraints);
65 }
66
67
68
69
70
71
72
73
74
75
76 public ProcessorResult(ConstraintValidationResult constraintValidationResult, Constrainable definition,
77 AttributeValueReader attributeValueReader, List<Constraint> constraints) {
78 this.constraintValidationResults = Collections.singletonList(constraintValidationResult);
79 this.definition = definition;
80 this.attributeValueReader = attributeValueReader;
81 this.constraints = constraints;
82 }
83
84
85
86
87
88
89 public ProcessorResult(List<ConstraintValidationResult> constraintValidationResults) {
90 this(constraintValidationResults, null, null);
91 }
92
93
94
95
96
97
98
99
100
101
102 public ProcessorResult(List<ConstraintValidationResult> constraintValidationResults, Constrainable definition,
103 AttributeValueReader attributeValueReader, Constraint... constraints) {
104 this.constraintValidationResults = constraintValidationResults;
105 this.definition = definition;
106 this.attributeValueReader = attributeValueReader;
107 this.constraints = Arrays.asList(constraints);
108 }
109
110
111
112
113
114
115 public boolean isSingleConstraintResult() {
116 return this.constraintValidationResults.size() == 1;
117 }
118
119
120
121
122
123
124 public boolean isDefinitionProvided() {
125 return definition != null;
126 }
127
128
129
130
131
132
133 public boolean isAttributeValueReaderProvided() {
134 return attributeValueReader != null;
135 }
136
137
138
139
140
141
142 public ConstraintValidationResult getFirstConstraintValidationResult() {
143 return this.constraintValidationResults.isEmpty() ? null : this.constraintValidationResults.get(0);
144 }
145
146
147
148
149 public List<ConstraintValidationResult> getConstraintValidationResults() {
150 return this.constraintValidationResults;
151 }
152
153
154
155
156 public Constrainable getDefinition() {
157 return this.definition;
158 }
159
160
161
162
163 public AttributeValueReader getAttributeValueReader() {
164 return this.attributeValueReader;
165 }
166
167
168
169
170 public List<Constraint> getConstraints() {
171 return this.constraints;
172 }
173
174 }