Open Kilda Java Documentation
ErrorData.java
Go to the documentation of this file.
1 /* Copyright 2017 Telstra Open Source
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package org.openkilda.messaging.error;
17 
18 import static com.google.common.base.MoreObjects.toStringHelper;
19 
21 
22 import com.fasterxml.jackson.annotation.JsonCreator;
23 import com.fasterxml.jackson.annotation.JsonInclude;
24 import com.fasterxml.jackson.annotation.JsonProperty;
25 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
26 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
27 
28 import java.util.Objects;
29 
33 @JsonSerialize
34 @JsonInclude(JsonInclude.Include.NON_NULL)
35 @JsonPropertyOrder({
36  "error-type",
37  "error-message",
38  "error-description"})
39 public class ErrorData extends MessageData {
43  private static final long serialVersionUID = 1L;
44 
48  @JsonProperty("error-type")
49  protected ErrorType errorType;
50 
54  @JsonProperty("error-message")
55  protected String errorMessage;
56 
60  @JsonProperty("error-description")
61  protected String errorDescription;
62 
70  @JsonCreator
71  public ErrorData(@JsonProperty("error-type") final ErrorType errorType,
72  @JsonProperty("error-message") final String errorMessage,
73  @JsonProperty("error-description") final String errorDescription) {
74  this.errorType = errorType;
75  this.errorMessage = errorMessage;
76  this.errorDescription = errorDescription;
77  }
78 
85  return errorType;
86  }
87 
93  public void setErrorType(final ErrorType errorType) {
94  this.errorType = errorType;
95  }
96 
102  public String getErrorMessage() {
103  return errorMessage;
104  }
105 
111  public void setErrorMessage(final String errorMessage) {
112  this.errorMessage = errorMessage;
113  }
114 
120  public String getErrorDescription() {
121  return errorDescription;
122  }
123 
129  public void setErrorDescription(final String errorDescription) {
130  this.errorDescription = errorDescription;
131  }
132 
136  @Override
137  public String toString() {
138  return toStringHelper(this)
139  .add("error-type", errorType)
140  .add("error-message", errorMessage)
141  .add("error-description", errorDescription)
142  .toString();
143  }
144 
148  @Override
149  public boolean equals(Object obj) {
150  if (this == obj) {
151  return true;
152  }
153 
154  if (obj == null || !(obj instanceof ErrorData)) {
155  return false;
156  }
157 
158  ErrorData that = (ErrorData) obj;
159  return Objects.equals(getErrorType(), that.getErrorType())
160  && Objects.equals(getErrorMessage(), that.getErrorMessage())
161  && Objects.equals(getErrorDescription(), that.getErrorDescription());
162  }
163 
167  @Override
168  public int hashCode() {
169  return Objects.hash(errorType, errorMessage, errorDescription);
170  }
171 }
void setErrorDescription(final String errorDescription)
Definition: ErrorData.java:129
void setErrorType(final ErrorType errorType)
Definition: ErrorData.java:93
description
Definition: setup.py:26
void setErrorMessage(final String errorMessage)
Definition: ErrorData.java:111