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