16 package org.openkilda.messaging.error;
18 import static com.google.common.base.MoreObjects.firstNonNull;
19 import static com.google.common.base.MoreObjects.toStringHelper;
24 import com.fasterxml.jackson.annotation.JsonCreator;
25 import com.fasterxml.jackson.annotation.JsonInclude;
26 import com.fasterxml.jackson.annotation.JsonProperty;
27 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
29 import java.io.Serializable;
30 import java.util.Objects;
36 @JsonInclude(JsonInclude.Include.NON_NULL)
41 private static final long serialVersionUID = 1L;
46 @JsonProperty(CORRELATION_ID)
47 private String correlationId;
52 @JsonProperty(TIMESTAMP)
53 private long timestamp;
58 @JsonProperty(
"error-type")
59 private String errorType;
64 @JsonProperty(
"error-message")
65 private String errorMessage;
70 @JsonProperty(
"error-description")
71 private String errorDescription;
83 public MessageError(@JsonProperty(CORRELATION_ID)
final String correlationId,
84 @JsonProperty(TIMESTAMP)
final long timestamp,
85 @JsonProperty(
"error-type")
final String
type,
86 @JsonProperty(
"error-message")
final String message,
87 @JsonProperty(
"error-description")
final String
description) {
88 this.correlationId = firstNonNull(correlationId, DEFAULT_CORRELATION_ID);
89 this.timestamp = timestamp;
90 this.errorType =
type;
91 this.errorMessage = message;
100 return toStringHelper(
this)
101 .add(CORRELATION_ID, correlationId)
102 .add(TIMESTAMP, timestamp)
103 .add(
"error-type", errorType)
104 .add(
"error-message", errorMessage)
105 .add(
"error-description", errorDescription)
114 return Objects.hash(correlationId, timestamp, errorType, errorMessage, errorDescription);
122 if (
this ==
object) {
125 if (
object == null || getClass() !=
object.getClass()) {
130 return Objects.
equals(this.correlationId, that.correlationId)
131 && Objects.equals(this.errorType, that.errorType)
132 && Objects.equals(this.errorMessage, that.errorMessage)
133 && Objects.equals(this.errorDescription, that.errorDescription);
boolean equals(Object object)
static final String DEFAULT_CORRELATION_ID
static final String CORRELATION_ID
static final String TIMESTAMP
MessageError(@JsonProperty(CORRELATION_ID) final String correlationId, @JsonProperty(TIMESTAMP) final long timestamp, @JsonProperty("error-type") final String type, @JsonProperty("error-message") final String message, @JsonProperty("error-description") final String description)