Clover Coverage Report - KS Contract Documentation Generator 0.0.1-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
37   188   26   1.42
0   131   0.7   13
26     1  
2    
 
  ValidationResultInfo       Line # 25 17 0% 10 27 0% 0.0
  ValidationResultInfo.Builder       Line # 110 20 0% 16 36 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2010 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may
3    * not use this file except in compliance with the License. You may obtain a copy of the License at
4    * http://www.osedu.org/licenses/ECL-2.0 Unless required by applicable law or agreed to in writing, software distributed
5    * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
6    * implied. See the License for the specific language governing permissions and limitations under the License.
7    */
8    package org.kuali.student.contract.model.test.source;
9   
10    import java.io.Serializable;
11    import java.util.List;
12   
13    import javax.xml.bind.annotation.XmlAccessType;
14    import javax.xml.bind.annotation.XmlAccessorType;
15    import javax.xml.bind.annotation.XmlAnyElement;
16    import javax.xml.bind.annotation.XmlElement;
17    import javax.xml.bind.annotation.XmlType;
18   
19    import org.kuali.student.contract.model.test.source.ModelBuilder;
20    import org.kuali.student.contract.model.test.source.ValidationResult;
21    import org.w3c.dom.Element;
22   
23    @XmlAccessorType(XmlAccessType.FIELD)
24    @XmlType(name = "ValidationResultInfo", propOrder = {"element", "level", "message", "_futureElements"})
 
25    public class ValidationResultInfo implements ValidationResult, Serializable {
26   
27    private static final long serialVersionUID = 1L;
28   
29    @XmlElement
30    private String element;
31    @XmlElement
32    private Integer level;
33    @XmlElement
34    private String message;
35    private transient Object invalidData;
36    @XmlAnyElement
37    private final List<Element> _futureElements;
38   
 
39  0 toggle private ValidationResultInfo() {
40  0 this.level = null;
41  0 this.message = null;
42  0 this.invalidData = null;
43  0 this._futureElements = null;
44    }
45   
 
46  0 toggle private ValidationResultInfo(ValidationResult builder) {
47  0 this.level = builder.getLevel();
48  0 this.element = builder.getElement();
49  0 this.message = builder.getMessage();
50  0 this.invalidData = builder.getInvalidData();
51  0 this._futureElements = null;
52    }
53   
54    /**
55    * Convenience method. Returns true if getErrorLevel() == ErrorLevel.OK
56    *
57    * @return true if getErrorLevel() == ErrorLevel.OK
58    */
 
59  0 toggle @Override
60    public boolean isOk() {
61  0 return getLevel() == ErrorLevel.OK.getLevel();
62    }
63   
64    /**
65    * Convenience method. Returns true if getErrorLevel() == ErrorLevel.WARN
66    *
67    * @return true if getErrorLevel() == ErrorLevel.WARN
68    */
 
69  0 toggle @Override
70    public boolean isWarn() {
71  0 return getLevel() == ErrorLevel.WARN.getLevel();
72    }
73   
74    /**
75    * Convenience method. Returns true if getErrorLevel() == ErrorLevel.ERROR
76    *
77    * @return true if getErrorLevel() == ErrorLevel.ERROR
78    */
 
79  0 toggle @Override
80    public boolean isError() {
81  0 return getLevel() == ErrorLevel.ERROR.getLevel();
82    }
83   
 
84  0 toggle @Override
85    public String toString() {
86  0 return "[" + level + "] Path: [" + element + "] - " + message + " data=[" + invalidData + "]";
87    }
88   
 
89  0 toggle @Override
90    public String getMessage() {
91  0 return message;
92    }
93   
 
94  0 toggle @Override
95    public String getElement() {
96  0 return element;
97    }
98   
 
99  0 toggle @Override
100    public Integer getLevel() {
101  0 return level;
102    }
103   
 
104  0 toggle @Override
105    public Object getInvalidData() {
106  0 return invalidData;
107    }
108   
109   
 
110    public static class Builder implements ModelBuilder<ValidationResultInfo>, ValidationResult {
111   
112    private String element;
113    private Integer level = ErrorLevel.OK.getLevel();
114    private String message;
115    private Object invalidData = null;
116   
 
117  0 toggle public Builder() {}
118   
 
119  0 toggle public Builder(ValidationResult validationResultInfo) {
120  0 this.element = validationResultInfo.getElement();
121  0 this.level = validationResultInfo.getLevel();
122  0 this.message = validationResultInfo.getMessage();
123  0 this.invalidData = validationResultInfo.getInvalidData();
124    }
125   
 
126  0 toggle @Override
127    public ValidationResultInfo build() {
128  0 return new ValidationResultInfo(this);
129    }
130   
 
131  0 toggle public String getElement() {
132  0 return element;
133    }
134   
 
135  0 toggle public void setElement(String element) {
136  0 this.element = element;
137    }
138   
 
139  0 toggle public Integer getLevel() {
140  0 return level;
141    }
142   
 
143  0 toggle public void setLevel(Integer level) {
144  0 this.level = level;
145    }
146   
 
147  0 toggle public String getMessage() {
148  0 return message;
149    }
150   
 
151  0 toggle public void setMessage(String message) {
152  0 this.message = message;
153    }
154   
 
155  0 toggle public Object getInvalidData() {
156  0 return invalidData;
157    }
158   
 
159  0 toggle public void setInvalidData(Object invalidData) {
160  0 this.invalidData = invalidData;
161    }
162   
 
163  0 toggle public void setError(String message) {
164  0 this.level = ErrorLevel.ERROR.getLevel();
165  0 this.message = message;
166    }
167   
 
168  0 toggle public void setWarn(String message) {
169  0 this.level = ErrorLevel.WARN.getLevel();
170  0 this.message = message;
171    }
172   
 
173  0 toggle @Override
174    public boolean isOk() {
175  0 return getLevel() == ErrorLevel.OK.getLevel();
176    }
177   
 
178  0 toggle @Override
179    public boolean isWarn() {
180  0 return getLevel() == ErrorLevel.WARN.getLevel();
181    }
182   
 
183  0 toggle @Override
184    public boolean isError() {
185  0 return getLevel() == ErrorLevel.ERROR.getLevel();
186    }
187    }
188    }