001package ca.uhn.fhir.validation; 002 003/* 004 * #%L 005 * HAPI FHIR - Core Library 006 * %% 007 * Copyright (C) 2014 - 2021 Smile CDR, Inc. 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023import org.apache.commons.lang3.builder.EqualsBuilder; 024import org.apache.commons.lang3.builder.HashCodeBuilder; 025import org.apache.commons.lang3.builder.ToStringBuilder; 026import org.apache.commons.lang3.builder.ToStringStyle; 027 028public class SingleValidationMessage { 029 030 private Integer myLocationCol; 031 private Integer myLocationLine; 032 private String myLocationString; 033 private String myMessage; 034 private ResultSeverityEnum mySeverity; 035 036 @Override 037 public boolean equals(Object obj) { 038 if (this == obj) { 039 return true; 040 } 041 if (obj == null) { 042 return false; 043 } 044 if (!(obj instanceof SingleValidationMessage)) { 045 return false; 046 } 047 SingleValidationMessage other = (SingleValidationMessage) obj; 048 EqualsBuilder b = new EqualsBuilder(); 049 b.append(myLocationCol, other.myLocationCol); 050 b.append(myLocationLine, other.myLocationLine); 051 b.append(myLocationString, other.myLocationString); 052 b.append(myMessage, other.myMessage); 053 b.append(mySeverity, other.mySeverity); 054 return b.isEquals(); 055 } 056 057 public Integer getLocationCol() { 058 return myLocationCol; 059 } 060 061 public Integer getLocationLine() { 062 return myLocationLine; 063 } 064 065 public String getLocationString() { 066 return myLocationString; 067 } 068 069 public String getMessage() { 070 return myMessage; 071 } 072 073 public ResultSeverityEnum getSeverity() { 074 return mySeverity; 075 } 076 077 @Override 078 public int hashCode() { 079 HashCodeBuilder b = new HashCodeBuilder(); 080 b.append(myLocationCol); 081 b.append(myLocationCol); 082 b.append(myLocationString); 083 b.append(myMessage); 084 b.append(mySeverity); 085 return b.toHashCode(); 086 } 087 088 public void setLocationCol(Integer theLocationCol) { 089 myLocationCol = theLocationCol; 090 } 091 092 public void setLocationLine(Integer theLocationLine) { 093 myLocationLine = theLocationLine; 094 } 095 096 public void setLocationString(String theLocationString) { 097 myLocationString = theLocationString; 098 } 099 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}