Open Kilda Java Documentation
FlowUpdateRequest.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.flow;
17 
18 import static com.google.common.base.MoreObjects.toStringHelper;
19 
23 
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.annotation.JsonPropertyOrder;
28 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
29 
30 import java.util.Objects;
31 
35 @JsonSerialize
36 @JsonInclude(JsonInclude.Include.NON_NULL)
37 @JsonPropertyOrder({
38  "command",
39  Utils.PAYLOAD})
40 public class FlowUpdateRequest extends CommandData {
44  private static final long serialVersionUID = 1L;
45 
49  @JsonProperty(Utils.PAYLOAD)
50  protected Flow payload;
51 
58  @JsonCreator
59  public FlowUpdateRequest(@JsonProperty(Utils.PAYLOAD) Flow payload) {
60  setPayload(payload);
61  }
62 
68  public Flow getPayload() {
69  return payload;
70  }
71 
77  public void setPayload(Flow payload) {
78  if (payload == null) {
79  throw new IllegalArgumentException("need to set payload");
80  }
81  this.payload = payload;
82  }
83 
87  @Override
88  public String toString() {
89  return toStringHelper(this)
90  .add(Utils.PAYLOAD, payload)
91  .toString();
92  }
93 
97  @Override
98  public int hashCode() {
99  return Objects.hash(payload);
100  }
101 
105  @Override
106  public boolean equals(Object object) {
107  if (this == object) {
108  return true;
109  }
110  if (object == null || getClass() != object.getClass()) {
111  return false;
112  }
113 
114  FlowUpdateRequest that = (FlowUpdateRequest) object;
115  return Objects.equals(getPayload(), that.getPayload());
116  }
117 }
static final String PAYLOAD
Definition: Utils.java:57