Open Kilda Java Documentation
CommandWithReplyToMessage.java
Go to the documentation of this file.
1 /* Copyright 2018 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 
24 import com.fasterxml.jackson.annotation.JsonCreator;
25 import com.fasterxml.jackson.annotation.JsonInclude;
26 import com.fasterxml.jackson.annotation.JsonProperty;
28 
29 import java.util.Objects;
30 
34 @JsonInclude(JsonInclude.Include.NON_NULL)
36 
37  @JsonProperty("reply_to")
38  protected String replyTo;
39 
49  @JsonCreator
50  public CommandWithReplyToMessage(@JsonProperty(PAYLOAD) final CommandData data,
51  @JsonProperty(TIMESTAMP) final long timestamp,
52  @JsonProperty(CORRELATION_ID) final String correlationId,
53  @JsonProperty(DESTINATION) final Destination destination,
54  @JsonProperty("reply_to") final String replyTo) {
55  super(data, timestamp, correlationId, destination);
56  this.replyTo = Objects.requireNonNull(replyTo, "reply_to must not be null");
57  }
58 
59  public String getReplyTo() {
60  return replyTo;
61  }
62 
63  @Override
64  public String toString() {
65  return toStringHelper(this)
66  .add(TIMESTAMP, timestamp)
67  .add(CORRELATION_ID, correlationId)
68  .add(DESTINATION, destination)
69  .add("replyTo", replyTo)
70  .add(PAYLOAD, data)
71  .toString();
72  }
73 }
static final String PAYLOAD
Definition: Utils.java:57
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