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