Open Kilda Java Documentation
InfoMessage.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.info;
17 
18 import static com.google.common.base.MoreObjects.toStringHelper;
21 import static org.openkilda.messaging.Utils.PAYLOAD;
22 import static org.openkilda.messaging.Utils.TIMESTAMP;
23 
26 
27 import com.fasterxml.jackson.annotation.JsonCreator;
28 import com.fasterxml.jackson.annotation.JsonInclude;
29 import com.fasterxml.jackson.annotation.JsonProperty;
30 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
31 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
32 
33 import java.util.Objects;
34 
38 @JsonSerialize
39 @JsonInclude(JsonInclude.Include.NON_NULL)
40 @JsonPropertyOrder(value = {
41  DESTINATION,
42  PAYLOAD,
43  TIMESTAMP,
44  CORRELATION_ID})
45 public class InfoMessage extends Message {
49  private static final long serialVersionUID = 1L;
50 
54  @JsonProperty(PAYLOAD)
55  private InfoData data;
56 
65  @JsonCreator
66  public InfoMessage(@JsonProperty(PAYLOAD) final InfoData data,
67  @JsonProperty(TIMESTAMP) final long timestamp,
68  @JsonProperty(CORRELATION_ID) final String correlationId,
69  @JsonProperty(DESTINATION) final Destination destination) {
70  super(timestamp, correlationId, destination);
71  setData(data);
72  }
73 
81  public InfoMessage(final InfoData data,
82  final long timestamp,
83  final String correlationId) {
84  super(timestamp, correlationId);
85  setData(data);
86  }
87 
93  public InfoData getData() {
94  return data;
95  }
96 
102  public void setData(final InfoData data) {
103  this.data = data;
104  }
105 
109  @Override
110  public String toString() {
111  return toStringHelper(this)
112  .add(TIMESTAMP, timestamp)
113  .add(CORRELATION_ID, correlationId)
114  .add(DESTINATION, destination)
115  .add(PAYLOAD, data)
116  .toString();
117  }
118 
119  @Override
120  public boolean equals(Object o) {
121  if (this == o) return true;
122  if (!(o instanceof InfoMessage)) return false;
123  InfoMessage that = (InfoMessage) o;
124  return Objects.equals(data, that.data) &&
125  timestamp == that.timestamp &&
126  correlationId.equals(that.correlationId) &&
127  destination == that.destination;
128  }
129 
130  @Override
131  public int hashCode() {
132 
133  return Objects.hash(data);
134  }
135 }
static final String PAYLOAD
Definition: Utils.java:57
value
Definition: nodes.py:62
static final String DESTINATION
Definition: Utils.java:51
static final String CORRELATION_ID
Definition: Utils.java:43
InfoMessage(final InfoData data, final long timestamp, final String correlationId)
static final String TIMESTAMP
Definition: Utils.java:35
InfoMessage(@JsonProperty(PAYLOAD) final InfoData data, @JsonProperty(TIMESTAMP) final long timestamp, @JsonProperty(CORRELATION_ID) final String correlationId, @JsonProperty(DESTINATION) final Destination destination)