Open Kilda Java Documentation
MeterInstall.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.model.rule;
17 
18 import com.fasterxml.jackson.annotation.JsonProperty;
19 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
20 import com.google.common.base.MoreObjects;
21 
22 import java.io.Serializable;
23 import java.util.Objects;
24 
28 @JsonSerialize
29 public class MeterInstall extends MeterDelete implements Serializable {
33  private static final long serialVersionUID = 1L;
34 
38  @JsonProperty(RuleConstants.BANDWIDTH)
39  private int bandwidth;
40 
44  public MeterInstall() {
45  }
46 
56  public MeterInstall(@JsonProperty(RuleConstants.FLOW_ID) String flowId,
57  @JsonProperty(RuleConstants.COOKIE) int cookie,
58  @JsonProperty(RuleConstants.SWITCH_ID) String switchId,
59  @JsonProperty(RuleConstants.METER_ID) int meterId,
60  @JsonProperty(RuleConstants.BANDWIDTH) int bandwidth) {
61  super(flowId, cookie, switchId, meterId);
62  this.bandwidth = bandwidth;
63  }
64 
70  public int getBandwidth() {
71  return bandwidth;
72  }
73 
79  public void setBandwidth(int bandwidth) {
80  this.bandwidth = bandwidth;
81  }
82 
86  @Override
87  public boolean equals(Object object) {
88  if (this == object) {
89  return true;
90  }
91  if (object == null || getClass() != object.getClass()) {
92  return false;
93  }
94 
95  MeterInstall that = (MeterInstall) object;
96  return Objects.equals(getFlowId(), that.getFlowId())
97  && getCookie() == that.getCookie()
98  && Objects.equals(getSwitchId(), that.getSwitchId())
99  && getMeterId() == that.getMeterId()
100  && getBandwidth() == that.getBandwidth();
101  }
102 
106  @Override
107  public int hashCode() {
108  return Objects.hash(getFlowId(), getCookie(), getSwitchId(), getMeterId(), getBandwidth());
109  }
110 
114  @Override
115  public String toString() {
116  return MoreObjects.toStringHelper(this)
121  .add(RuleConstants.BANDWIDTH, bandwidth)
122  .toString();
123  }
124 }
MeterInstall(@JsonProperty(RuleConstants.FLOW_ID) String flowId, @JsonProperty(RuleConstants.COOKIE) int cookie, @JsonProperty(RuleConstants.SWITCH_ID) String switchId, @JsonProperty(RuleConstants.METER_ID) int meterId, @JsonProperty(RuleConstants.BANDWIDTH) int bandwidth)