d4c7671c4539bb6455b70bb15760b2bf8e355e56
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / test / structures / Lst.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.*;
11
12 public class Lst extends YangElement {
13     private Set<LstItem> lstItems;
14
15     public Lst(String name) {
16         super(name);
17         lstItems = new HashSet<>();
18     }
19
20     public Lst addLstItem(LstItem lstItem) {
21         lstItem.setLstName(name);
22         while (this.lstItems.contains(lstItem)) {
23             lstItem.incNumOfEqualItems();
24         }
25         this.lstItems.add(lstItem);
26         return this;
27     }
28
29     public Set<LstItem> getLstItems() {
30         return lstItems;
31     }
32
33     @Override
34     public boolean equals(Object obj) {
35         if (this == obj) {
36             return true;
37         }
38         if (!this.getClass().equals(obj.getClass())) {
39             return false;
40         }
41         if (!super.equals(obj)) {
42             return false;
43         }
44         Lst lst = (Lst) obj;
45         if (this.lstItems == null) {
46             if (lst.lstItems != null) {
47                 return false;
48             }
49         } else if (!this.lstItems.equals(lst.lstItems)) {
50             return false;
51         }
52         return true;
53     }
54
55     @Override
56     public int hashCode() {
57         final int prime = 31;
58         int result = super.hashCode();
59         result = prime * result + ((lstItems == null) ? 0 : lstItems.hashCode());
60         return result;
61     }
62
63 }