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;
11 import java.util.HashMap;
14 public class LstItem {
17 Map<String, LfLst> lfLsts;
18 Map<String, Lst> lsts;
19 Map<String, Cont> conts;
20 private int numOfEqualItems = 0;
23 lfs = new HashMap<>();
24 conts = new HashMap<>();
25 lfLsts = new HashMap<>();
26 lsts = new HashMap<>();
29 public Map<String, Lst> getLsts() {
33 public Map<String, Cont> getConts() {
37 public Map<String, LfLst> getLfLsts() {
41 public Map<String, Lf> getLfs() {
45 public String getLstName() {
49 public LstItem addLf(Lf lf) {
50 lfs.put(lf.getName(), lf);
54 public LstItem addLf(String name, Object value) {
55 lfs.put(name, new Lf(name, value));
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);
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);
71 public void addCont(Cont cont) {
72 conts.put(cont.getName(), cont);
75 public void incNumOfEqualItems() {
76 this.numOfEqualItems++;
80 public boolean equals(Object obj) {
84 if (!this.getClass().equals(obj.getClass())) {
87 LstItem lstItem = (LstItem) obj;
88 if (this.conts == null) {
89 if (lstItem.conts != null) {
92 } else if (!this.conts.equals(lstItem.conts)) {
95 if (this.lfs == null) {
96 if (lstItem.lfs != null) {
99 } else if (!this.lfs.equals(lstItem.lfs)) {
102 if (this.lfLsts == null) {
103 if (lstItem.lfLsts != null) {
106 } else if (!this.lfLsts.equals(lstItem.lfLsts)) {
109 if (this.lsts == null) {
110 if (lstItem.lsts != null) {
113 } else if (!this.lsts.equals(lstItem.lsts)) {
116 if (this.numOfEqualItems != lstItem.numOfEqualItems) {
123 public int hashCode() {
124 final int prime = 31;
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;
135 public String toString() {
136 return "lst item of " + lstName;
139 public void setLstName(String name) {