View Javadoc
1   package ca.uhn.fhir.validation;
2   
3   /*
4    * #%L
5    * HAPI FHIR - Core Library
6    * %%
7    * Copyright (C) 2014 - 2018 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import org.apache.commons.lang3.builder.EqualsBuilder;
24  import org.apache.commons.lang3.builder.HashCodeBuilder;
25  import org.apache.commons.lang3.builder.ToStringBuilder;
26  import org.apache.commons.lang3.builder.ToStringStyle;
27  
28  public class SingleValidationMessage {
29  
30  	private Integer myLocationCol;
31  	private Integer myLocationLine;
32  	private String myLocationString;
33  	private String myMessage;
34  	private ResultSeverityEnum mySeverity;
35  
36  	@Override
37  	public boolean equals(Object obj) {
38  		if (this == obj) {
39  			return true;
40  		}
41  		if (obj == null) {
42  			return false;
43  		}
44  		if (!(obj instanceof SingleValidationMessage)) {
45  			return false;
46  		}
47  		SingleValidationMessage other = (SingleValidationMessage) obj;
48  		EqualsBuilder b = new EqualsBuilder();
49  		b.append(myLocationCol, other.myLocationCol);
50  		b.append(myLocationLine, other.myLocationLine);
51  		b.append(myLocationString, other.myLocationString);
52  		b.append(myMessage, other.myMessage);
53  		b.append(mySeverity, other.mySeverity);
54  		return b.isEquals();
55  	}
56  
57  	public Integer getLocationCol() {
58  		return myLocationCol;
59  	}
60  
61  	public Integer getLocationLine() {
62  		return myLocationLine;
63  	}
64  
65  	public String getLocationString() {
66  		return myLocationString;
67  	}
68  
69  	public String getMessage() {
70  		return myMessage;
71  	}
72  
73  	public ResultSeverityEnum getSeverity() {
74  		return mySeverity;
75  	}
76  
77  	@Override
78  	public int hashCode() {
79  		HashCodeBuilder b = new HashCodeBuilder();
80  		b.append(myLocationCol);
81  		b.append(myLocationCol);
82  		b.append(myLocationString);
83  		b.append(myMessage);
84  		b.append(mySeverity);
85  		return b.toHashCode();
86  	}
87  
88  	public void setLocationCol(Integer theLocationCol) {
89  		myLocationCol = theLocationCol;
90  	}
91  
92  	public void setLocationLine(Integer theLocationLine) {
93  		myLocationLine = theLocationLine;
94  	}
95  
96  	public void setLocationString(String theLocationString) {
97  		myLocationString = theLocationString;
98  	}
99  
100 	public void setMessage(String theMessage) {
101 		myMessage = theMessage;
102 	}
103 
104 	public void setSeverity(ResultSeverityEnum theSeverity) {
105 		mySeverity = theSeverity;
106 	}
107 
108 	@Override
109 	public String toString() {
110 		ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
111 		if (myLocationCol != null || myLocationLine != null) {
112 			b.append("col", myLocationCol);
113 			b.append("row", myLocationLine);
114 		}
115 		if (myLocationString != null) {
116 			b.append("locationString", myLocationString);
117 		}
118 		b.append("message", myMessage);
119 		if (mySeverity != null) {
120 			b.append("severity", mySeverity.getCode());
121 		}
122 		return b.toString();
123 	}
124 
125 }