001package ca.uhn.fhir.validation;
002
003/*
004 * #%L
005 * HAPI FHIR - Core Library
006 * %%
007 * Copyright (C) 2014 - 2023 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 String myMessageId;
035        private ResultSeverityEnum mySeverity;
036
037        /**
038         * Constructor
039         */
040        public SingleValidationMessage() {
041                super();
042        }
043
044        @Override
045        public boolean equals(Object obj) {
046                if (this == obj) {
047                        return true;
048                }
049                if (obj == null) {
050                        return false;
051                }
052                if (!(obj instanceof SingleValidationMessage)) {
053                        return false;
054                }
055                SingleValidationMessage other = (SingleValidationMessage) obj;
056                EqualsBuilder b = new EqualsBuilder();
057                b.append(myLocationCol, other.myLocationCol);
058                b.append(myLocationLine, other.myLocationLine);
059                b.append(myLocationString, other.myLocationString);
060                b.append(myMessage, other.myMessage);
061                b.append(mySeverity, other.mySeverity);
062                return b.isEquals();
063        }
064
065        public Integer getLocationCol() {
066                return myLocationCol;
067        }
068
069        public Integer getLocationLine() {
070                return myLocationLine;
071        }
072
073        public String getLocationString() {
074                return myLocationString;
075        }
076
077        public String getMessage() {
078                return myMessage;
079        }
080
081        public String getMessageId() {
082                return myMessageId;
083        }
084
085        public ResultSeverityEnum getSeverity() {
086                return mySeverity;
087        }
088
089        @Override
090        public int hashCode() {
091                HashCodeBuilder b = new HashCodeBuilder();
092                b.append(myLocationCol);
093                b.append(myLocationCol);
094                b.append(myLocationString);
095                b.append(myMessage);
096                b.append(mySeverity);
097                return b.toHashCode();
098        }
099
100        public void setLocationCol(Integer theLocationCol) {
101                myLocationCol = theLocationCol;
102        }
103
104        public void setLocationLine(Integer theLocationLine) {
105                myLocationLine = theLocationLine;
106        }
107
108        public void setLocationString(String theLocationString) {
109                myLocationString = theLocationString;
110        }
111
112        public void setMessage(String theMessage) {
113                myMessage = theMessage;
114        }
115
116        public void setMessageId(String messageId) {
117                myMessageId = messageId;
118        }
119
120        public void setSeverity(ResultSeverityEnum theSeverity) {
121                mySeverity = theSeverity;
122        }
123
124        @Override
125        public String toString() {
126                ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
127                if (myLocationCol != null || myLocationLine != null) {
128                        b.append("col", myLocationCol);
129                        b.append("row", myLocationLine);
130                }
131                if (myLocationString != null) {
132                        b.append("locationString", myLocationString);
133                }
134                b.append("message", myMessage);
135                if (myMessageId != null) {
136                        b.append(myMessageId);
137                }
138                if (mySeverity != null) {
139                        b.append("severity", mySeverity.getCode());
140                }
141                return b.toString();
142        }
143
144}