Open Kilda Java Documentation
FlowInfoData.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.flow;
17 
22 
23 import com.fasterxml.jackson.annotation.JsonCreator;
24 import com.fasterxml.jackson.annotation.JsonInclude;
25 import com.fasterxml.jackson.annotation.JsonProperty;
26 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
27 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
28 import com.google.common.base.MoreObjects;
29 
30 import java.util.Objects;
31 
35 @JsonSerialize
36 @JsonInclude(JsonInclude.Include.NON_NULL)
37 @JsonPropertyOrder({
38  "message_type",
39  Utils.PAYLOAD,
40  "operation",
41  Utils.CORRELATION_ID})
42 public class FlowInfoData extends InfoData {
46  private static final long serialVersionUID = 1L;
47 
51  @JsonProperty(Utils.FLOW_ID)
52  private String flowId;
53 
57  @JsonProperty(Utils.PAYLOAD)
58  private ImmutablePair<Flow, Flow> payload;
59 
63  @JsonProperty(Utils.CORRELATION_ID)
64  protected String correlationId;
65 
69  @JsonProperty("operation")
70  private FlowOperation operation;
71 
75  public FlowInfoData() {
76  }
77 
86  @JsonCreator
87  public FlowInfoData(@JsonProperty(Utils.FLOW_ID) final String flowId,
88  @JsonProperty(Utils.PAYLOAD) ImmutablePair<Flow, Flow> payload,
89  @JsonProperty("operation") FlowOperation operation,
90  @JsonProperty(Utils.CORRELATION_ID) String correlationId) {
91  this.flowId = flowId;
92  this.payload = payload;
93  this.operation = operation;
94  this.correlationId = correlationId;
95  }
96 
102  public String getFlowId() {
103  return flowId;
104  }
105 
111  public void setFlowId(String flowId) {
112  this.flowId = flowId;
113  }
114 
121  return payload;
122  }
123 
129  public void setPayload(ImmutablePair<Flow, Flow> payload) {
130  this.payload = payload;
131  }
132 
139  return operation;
140  }
141 
147  public void setOperation(FlowOperation operation) {
148  this.operation = operation;
149  }
150 
156  public String getCorrelationId() {
157  return correlationId;
158  }
159 
165  public void setCorrelationId(String correlationId) {
166  this.correlationId = correlationId;
167  }
168 
172  @Override
173  public String toString() {
174  return MoreObjects.toStringHelper(this)
175  .add(Utils.FLOW_ID, flowId)
176  .add(Utils.PAYLOAD, payload)
177  .add("operation", operation)
178  .add(Utils.CORRELATION_ID, correlationId)
179  .toString();
180  }
181 
185  @Override
186  public boolean equals(Object object) {
187  if (this == object) {
188  return true;
189  }
190  if (object == null || getClass() != object.getClass()) {
191  return false;
192  }
193 
194  FlowInfoData that = (FlowInfoData) object;
195  return Objects.equals(getFlowId(), that.getFlowId())
196  && Objects.equals(getOperation(), that.getOperation())
197  && Objects.equals(getPayload(), that.getPayload())
198  && Objects.equals(getCorrelationId(), that.getCorrelationId());
199  }
200 
204  @Override
205  public int hashCode() {
206  return Objects.hash(getFlowId(), getPayload(), getOperation(), getCorrelationId());
207  }
208 }
static final String PAYLOAD
Definition: Utils.java:57
FlowInfoData(@JsonProperty(Utils.FLOW_ID) final String flowId, @JsonProperty(Utils.PAYLOAD) ImmutablePair< Flow, Flow > payload, @JsonProperty("operation") FlowOperation operation, @JsonProperty(Utils.CORRELATION_ID) String correlationId)
ImmutablePair< Flow, Flow > getPayload()
void setOperation(FlowOperation operation)
static final String CORRELATION_ID
Definition: Utils.java:43
void setPayload(ImmutablePair< Flow, Flow > payload)
static final String FLOW_ID
Definition: Utils.java:61