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
22 import java.util.Arrays;
23 import java.util.Collections;
24 import java.util.List;
25
26
27
28
29
30 public class ProcessorResult {
31
32 private final transient List<Constraint> constraints;
33 private final transient Constrainable definition;
34 private final transient AttributeValueReader attributeValueReader;
35
36 private final List<ConstraintValidationResult> constraintValidationResults;
37
38 public ProcessorResult(ConstraintValidationResult constraintValidationResult) {
39 this(constraintValidationResult, null, null);
40 }
41
42 public ProcessorResult(ConstraintValidationResult constraintValidationResult, Constrainable definition, AttributeValueReader attributeValueReader, Constraint... constraints) {
43 this.constraintValidationResults = Collections.singletonList(constraintValidationResult);
44 this.definition = definition;
45 this.attributeValueReader = attributeValueReader;
46 this.constraints = Arrays.asList(constraints);
47 }
48
49 public ProcessorResult(List<ConstraintValidationResult> constraintValidationResults) {
50 this(constraintValidationResults, null, null);
51 }
52
53 public ProcessorResult(List<ConstraintValidationResult> constraintValidationResults, Constrainable definition, AttributeValueReader attributeValueReader, Constraint... constraints) {
54 this.constraintValidationResults = constraintValidationResults;
55 this.definition = definition;
56 this.attributeValueReader = attributeValueReader;
57 this.constraints = Arrays.asList(constraints);
58 }
59
60 public boolean isSingleConstraintResult() {
61 return this.constraintValidationResults.size() == 1;
62 }
63
64 public boolean isDefinitionProvided() {
65 return definition != null;
66 }
67
68 public boolean isAttributeValueReaderProvided() {
69 return attributeValueReader != null;
70 }
71
72 public ConstraintValidationResult getFirstConstraintValidationResult() {
73 return this.constraintValidationResults.isEmpty() ? null : this.constraintValidationResults.get(0);
74 }
75
76
77
78
79 public List<ConstraintValidationResult> getConstraintValidationResults() {
80 return this.constraintValidationResults;
81 }
82
83
84
85
86 public Constrainable getDefinition() {
87 return this.definition;
88 }
89
90
91
92
93 public AttributeValueReader getAttributeValueReader() {
94 return this.attributeValueReader;
95 }
96
97
98
99
100 public List<Constraint> getConstraints() {
101 return this.constraints;
102 }
103
104 }