Merge "Simplify method isMutualExclusive in Subnet. Remove redundant 'if' statements."
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / test / structures / LstItem.java
1 package org.opendaylight.controller.sal.restconf.impl.test.structures;
2
3 import java.util.HashMap;
4 import java.util.Map;
5
6 public class LstItem {
7     String lstName;
8     Map<String, Lf> lfs;
9     Map<String, LfLst> lfLsts;
10     Map<String, Lst> lsts;
11     Map<String, Cont> conts;
12     private int numOfEqualItems = 0;
13
14     public LstItem() {
15         lfs = new HashMap<>();
16         conts = new HashMap<>();
17         lfLsts = new HashMap<>();
18         lsts = new HashMap<>();
19     }
20
21     public Map<String, Lst> getLsts() {
22         return lsts;
23     }
24
25     public Map<String, Cont> getConts() {
26         return conts;
27     }
28
29     public Map<String, LfLst> getLfLsts() {
30         return lfLsts;
31     }
32
33     public Map<String, Lf> getLfs() {
34         return lfs;
35     }
36
37     public String getLstName() {
38         return lstName;
39     }
40
41     public LstItem addLf(Lf lf) {
42         lfs.put(lf.getName(), lf);
43         return this;
44     }
45
46     public LstItem addLf(String name, Object value) {
47         lfs.put(name, new Lf(name, value));
48         return this;
49     }
50
51     public void addLfLst(LfLst lfLst) {
52         lfLsts.put(lfLst.getName(), lfLst);
53     }
54
55     public void addLst(Lst lst) {
56         lsts.put(lst.getName(), lst);
57     }
58
59     public void addCont(Cont cont) {
60         conts.put(cont.getName(), cont);
61     }
62
63     public void incNumOfEqualItems() {
64         this.numOfEqualItems++;
65     }
66
67     @Override
68     public boolean equals(Object obj) {
69         if (this == obj) {
70             return true;
71         }
72         if (!this.getClass().equals(obj.getClass())) {
73             return false;
74         }
75         LstItem lstItem = (LstItem) obj;
76         if (this.conts == null) {
77             if (lstItem.conts != null) {
78                 return false;
79             }
80         } else if (!this.conts.equals(lstItem.conts)) {
81             return false;
82         }
83         if (this.lfs == null) {
84             if (lstItem.lfs != null) {
85                 return false;
86             }
87         } else if (!this.lfs.equals(lstItem.lfs)) {
88             return false;
89         }
90         if (this.lfLsts == null) {
91             if (lstItem.lfLsts != null) {
92                 return false;
93             }
94         } else if (!this.lfLsts.equals(lstItem.lfLsts)) {
95             return false;
96         }
97         if (this.lsts == null) {
98             if (lstItem.lsts != null) {
99                 return false;
100             }
101         } else if (!this.lsts.equals(lstItem.lsts)) {
102             return false;
103         }
104         if (this.numOfEqualItems != lstItem.numOfEqualItems) {
105             return false;
106         }
107         return true;
108     }
109
110     @Override
111     public int hashCode() {
112         final int prime = 31;
113         int result = 1;
114         result = prime * result + ((lfs == null) ? 0 : lfs.hashCode());
115         result = prime * result + ((lfLsts == null) ? 0 : lfLsts.hashCode());
116         result = prime * result + ((lsts == null) ? 0 : lsts.hashCode());
117         result = prime * result + ((conts == null) ? 0 : conts.hashCode());
118         result = prime * result + numOfEqualItems;
119         return result;
120     }
121
122     @Override
123     public String toString() {
124         return "lst item of " + lstName;
125     }
126
127     public void setLstName(String name) {
128         this.lstName = name;
129     }
130
131 }