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 public ProcessorResult(ConstraintValidationResult constraintValidationResult, Constrainable definition, AttributeValueReader attributeValueReader, Constraint... constraints) {
59 this.constraintValidationResults = Collections.singletonList(constraintValidationResult);
60 this.definition = definition;
61 this.attributeValueReader = attributeValueReader;
62 this.constraints = Arrays.asList(constraints);
63 }
64
65
66
67
68
69
70
71
72
73 public ProcessorResult(ConstraintValidationResult constraintValidationResult, Constrainable definition, AttributeValueReader attributeValueReader, List<Constraint> constraints) {
74 this.constraintValidationResults = Collections.singletonList(constraintValidationResult);
75 this.definition = definition;
76 this.attributeValueReader = attributeValueReader;
77 this.constraints = constraints;
78 }
79
80
81
82
83
84
85 public ProcessorResult(List<ConstraintValidationResult> constraintValidationResults) {
86 this(constraintValidationResults, null, null);
87 }
88
89
90
91
92
93
94
95
96
97 public ProcessorResult(List<ConstraintValidationResult> constraintValidationResults, Constrainable definition, AttributeValueReader attributeValueReader, Constraint... constraints) {
98 this.constraintValidationResults = constraintValidationResults;
99 this.definition = definition;
100 this.attributeValueReader = attributeValueReader;
101 this.constraints = Arrays.asList(constraints);
102 }
103
104
105
106
107
108
109 public boolean isSingleConstraintResult() {
110 return this.constraintValidationResults.size() == 1;
111 }
112
113
114
115
116
117
118 public boolean isDefinitionProvided() {
119 return definition != null;
120 }
121
122
123
124
125
126
127 public boolean isAttributeValueReaderProvided() {
128 return attributeValueReader != null;
129 }
130
131
132
133
134
135
136 public ConstraintValidationResult getFirstConstraintValidationResult() {
137 return this.constraintValidationResults.isEmpty() ? null : this.constraintValidationResults.get(0);
138 }
139
140
141
142
143 public List<ConstraintValidationResult> getConstraintValidationResults() {
144 return this.constraintValidationResults;
145 }
146
147
148
149
150 public Constrainable getDefinition() {
151 return this.definition;
152 }
153
154
155
156
157 public AttributeValueReader getAttributeValueReader() {
158 return this.attributeValueReader;
159 }
160
161
162
163
164 public List<Constraint> getConstraints() {
165 return this.constraints;
166 }
167
168 }