Merge "Bug 7826: Data validation failed for path"
[genius.git] / mdsalutil / mdsalutil-api / src / main / java / org / opendaylight / genius / mdsalutil / BucketInfo.java
1 /*
2  * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.genius.mdsalutil;
9
10 import com.google.common.base.MoreObjects;
11 import java.io.Serializable;
12 import java.util.List;
13 import java.util.Objects;
14 import org.opendaylight.yangtools.util.EvenMoreObjects;
15
16 public class BucketInfo extends ActionInfoList implements Serializable {
17
18     private static final long serialVersionUID = 1L;
19
20     private Integer weight = 0;
21     private Long watchPort = 0xffffffffL;
22     private Long watchGroup = 0xffffffffL;
23
24     public BucketInfo(List<ActionInfo> listActions) {
25         super(listActions);
26     }
27
28     public BucketInfo(List<ActionInfo> actionInfos, Integer weight, Long watchPort, Long watchGroup) {
29         super(actionInfos);
30         this.weight = weight;
31         this.watchPort = watchPort;
32         this.watchGroup = watchGroup;
33     }
34
35     public void setWeight(Integer bucketWeight) {
36         weight = bucketWeight;
37     }
38
39     public Integer getWeight() {
40         return weight;
41     }
42
43     public Long getWatchPort() {
44         return watchPort;
45     }
46
47     public void setWatchPort(Long watchPort) {
48         this.watchPort = watchPort;
49     }
50
51     public Long getWatchGroup() {
52         return watchGroup;
53     }
54
55     public void setWatchGroup(Long watchGroup) {
56         this.watchGroup = watchGroup;
57     }
58
59     @Override
60     public String toString() {
61         return MoreObjects.toStringHelper(this).add("actionInfos", getActionInfos()).add("weight", weight)
62                 .add("watchPort", watchPort).add("watchGroup", watchGroup).toString();
63     }
64
65     @Override
66     public int hashCode() {
67         return Objects.hash(getActionInfos(), weight, watchPort, watchGroup);
68     }
69
70     @Override
71     public boolean equals(Object obj) {
72         return EvenMoreObjects.equalsHelper(this, obj,
73             (self, other) -> Objects.equals(self.getActionInfos(), other.getActionInfos())
74                           && Objects.equals(self.weight, other.weight)
75                           && Objects.equals(self.watchPort, other.watchPort)
76                           && Objects.equals(self.watchGroup, other.watchGroup));
77     }
78 }