Open Kilda Java Documentation
CommandMessage.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.command;
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 
36 @JsonSerialize
37 @JsonInclude(JsonInclude.Include.NON_NULL)
38 @JsonPropertyOrder(value = {
39  DESTINATION,
40  PAYLOAD,
41  TIMESTAMP,
42  CORRELATION_ID})
43 public class CommandMessage extends Message {
47  private static final long serialVersionUID = 1L;
48 
52  @JsonProperty(PAYLOAD)
53  protected CommandData data;
54 
63  @JsonCreator
64  public CommandMessage(@JsonProperty(PAYLOAD) final CommandData data,
65  @JsonProperty(TIMESTAMP) final long timestamp,
66  @JsonProperty(CORRELATION_ID) final String correlationId,
67  @JsonProperty(DESTINATION) final Destination destination) {
68  super(timestamp, correlationId, destination);
69  setData(data);
70  }
71 
73  final long timestamp,
74  final String correlationId) {
75  super(timestamp, correlationId);
76  setData(data);
77  }
78 
84  public CommandData getData() {
85  return data;
86  }
87 
93  public void setData(final CommandData data) {
94  this.data = data;
95  }
96 
100  @Override
101  public String toString() {
102  return toStringHelper(this)
103  .add(TIMESTAMP, timestamp)
104  .add(CORRELATION_ID, correlationId)
105  .add(DESTINATION, destination)
106  .add(PAYLOAD, data)
107  .toString();
108  }
109 }
static final String PAYLOAD
Definition: Utils.java:57
value
Definition: nodes.py:62
CommandMessage(final CommandData data, final long timestamp, final String correlationId)
static final String DESTINATION
Definition: Utils.java:51
static final String CORRELATION_ID
Definition: Utils.java:43
static final String TIMESTAMP
Definition: Utils.java:35