16 package org.openkilda.messaging.command.flow;
18 import static com.google.common.base.MoreObjects.toStringHelper;
26 import com.fasterxml.jackson.annotation.JsonCreator;
27 import com.fasterxml.jackson.annotation.JsonInclude;
28 import com.fasterxml.jackson.annotation.JsonProperty;
29 import com.fasterxml.jackson.annotation.JsonPropertyOrder;
30 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
32 import java.util.Objects;
41 @JsonInclude(JsonInclude.Include.NON_NULL)
58 private static final long serialVersionUID = 1L;
63 @JsonProperty(
"meter_id")
64 protected Long meterId;
69 @JsonProperty("bandwidth")
70 private Long bandwidth;
75 @JsonProperty("output_vlan_type")
81 @JsonProperty("input_vlan_id")
82 private Integer inputVlanId;
87 @JsonProperty("output_vlan_id")
88 private Integer outputVlanId;
108 @JsonProperty(FLOW_ID) final String
id,
109 @JsonProperty("cookie") final Long cookie,
111 @JsonProperty("input_port") final Integer inputPort,
112 @JsonProperty("output_port") final Integer outputPort,
113 @JsonProperty("input_vlan_id") final Integer inputVlanId,
114 @JsonProperty("output_vlan_id") final Integer outputVlanId,
115 @JsonProperty("output_vlan_type") final
OutputVlanType outputVlanType,
116 @JsonProperty("bandwidth") final Long bandwidth,
117 @JsonProperty("meter_id") final Long meterId) {
118 super(transactionId,
id, cookie, switchId, inputPort, outputPort);
119 setInputVlanId(inputVlanId);
120 setOutputVlanId(outputVlanId);
121 setOutputVlanType(outputVlanType);
122 setBandwidth(bandwidth);
141 if (bandwidth == null) {
142 throw new IllegalArgumentException(
"need to set bandwidth");
143 }
else if (bandwidth < 0L) {
144 throw new IllegalArgumentException(
"need to set non negative bandwidth");
146 this.bandwidth = bandwidth;
155 return outputVlanType;
164 if (outputVlanType == null) {
165 throw new IllegalArgumentException(
"need to set output_vlan_type");
167 throw new IllegalArgumentException(
"need to set valid values for output_vlan_id and output_vlan_type");
169 this.outputVlanType = outputVlanType;
188 if (inputVlanId == null) {
189 this.inputVlanId = 0;
191 this.inputVlanId = inputVlanId;
193 throw new IllegalArgumentException(
"need to set valid value for input_vlan_id");
212 if (outputVlanId == null) {
213 this.outputVlanId = 0;
215 this.outputVlanId = outputVlanId;
217 throw new IllegalArgumentException(
"need to set valid value for output_vlan_id");
236 if (meterId == null) {
237 throw new IllegalArgumentException(
"need to set meterId");
238 }
else if (meterId < 0) {
239 throw new IllegalArgumentException(
"need to set non negative meterId");
241 this.meterId = meterId;
249 return toStringHelper(
this)
250 .add(TRANSACTION_ID, transactionId)
252 .add(
"cookie", cookie)
253 .add(
"switch_id", switchId)
254 .add(
"input_port", inputPort)
255 .add(
"output_port", outputPort)
256 .add(
"input_vlan_id", inputVlanId)
257 .add(
"output_vlan_id", outputVlanId)
258 .add(
"output_vlan_type", outputVlanType)
259 .add(
"bandwidth", bandwidth)
260 .add(
"meter_id", meterId)
269 if (
this ==
object) {
272 if (
object == null || getClass() !=
object.getClass()) {
278 && Objects.equals(getId(), that.
getId())
279 && Objects.equals(getCookie(), that.
getCookie())
280 && Objects.equals(getSwitchId(), that.
getSwitchId())
287 && Objects.equals(getMeterId(), that.
getMeterId());
295 return Objects.hash(transactionId,
id, cookie, switchId, inputPort, outputPort,
296 inputVlanId, outputVlanId, outputVlanType, bandwidth, meterId);
static boolean validateVlanRange(final Integer vlanId)
Integer getOutputVlanId()
void setOutputVlanType(final OutputVlanType outputVlanType)
void setOutputVlanId(final Integer outputVlanId)
void setBandwidth(final Long bandwidth)
OutputVlanType getOutputVlanType()
static final String TRANSACTION_ID
void setMeterId(final Long meterId)
static boolean validateOutputVlanType(final Integer outputVlanId, final OutputVlanType outputVlanType)
void setInputVlanId(final Integer inputVlanId)
static final String FLOW_ID
boolean equals(Object object)