2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.sal.restconf.impl.test.structures;
10 import static org.junit.Assert.assertFalse;
12 import java.util.HashMap;
15 public class LstItem {
18 Map<String, LfLst> lfLsts;
19 Map<String, Lst> lsts;
20 Map<String, Cont> conts;
21 private int numOfEqualItems = 0;
24 lfs = new HashMap<>();
25 conts = new HashMap<>();
26 lfLsts = new HashMap<>();
27 lsts = new HashMap<>();
30 public Map<String, Lst> getLsts() {
34 public Map<String, Cont> getConts() {
38 public Map<String, LfLst> getLfLsts() {
42 public Map<String, Lf> getLfs() {
46 public String getLstName() {
50 public LstItem addLf(Lf lf) {
51 lfs.put(lf.getName(), lf);
55 public LstItem addLf(String name, Object value) {
56 lfs.put(name, new Lf(name, value));
60 public void addLfLst(LfLst lfLst) {
61 assertFalse("Found multiple leaf list elements for " + lfLst.getName(), lfLsts.containsKey(lfLst.getName()));
62 lfLsts.put(lfLst.getName(), lfLst);
65 public void addLst(Lst lst) {
66 assertFalse("Found multiple list elements for " + lst.getName(), lsts.containsKey(lst.getName()));
67 lsts.put(lst.getName(), lst);
70 public void addCont(Cont cont) {
71 conts.put(cont.getName(), cont);
74 public void incNumOfEqualItems() {
75 this.numOfEqualItems++;
79 public boolean equals(Object obj) {
83 if (!this.getClass().equals(obj.getClass())) {
86 LstItem lstItem = (LstItem) obj;
87 if (this.conts == null) {
88 if (lstItem.conts != null) {
91 } else if (!this.conts.equals(lstItem.conts)) {
94 if (this.lfs == null) {
95 if (lstItem.lfs != null) {
98 } else if (!this.lfs.equals(lstItem.lfs)) {
101 if (this.lfLsts == null) {
102 if (lstItem.lfLsts != null) {
105 } else if (!this.lfLsts.equals(lstItem.lfLsts)) {
108 if (this.lsts == null) {
109 if (lstItem.lsts != null) {
112 } else if (!this.lsts.equals(lstItem.lsts)) {
115 if (this.numOfEqualItems != lstItem.numOfEqualItems) {
122 public int hashCode() {
123 final int prime = 31;
125 result = prime * result + ((lfs == null) ? 0 : lfs.hashCode());
126 result = prime * result + ((lfLsts == null) ? 0 : lfLsts.hashCode());
127 result = prime * result + ((lsts == null) ? 0 : lsts.hashCode());
128 result = prime * result + ((conts == null) ? 0 : conts.hashCode());
129 result = prime * result + numOfEqualItems;
134 public String toString() {
135 return "lst item of " + lstName;
138 public void setLstName(String name) {