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