Test composite node with empty conts and lists to Json
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / test / structures / Lst.java
1 package org.opendaylight.controller.sal.restconf.impl.test.structures;
2
3 import java.util.*;
4
5 public class Lst extends YangElement {
6     private Set<LstItem> lstItems;
7
8     public Lst(String name) {
9         super(name);
10         lstItems = new HashSet<>();
11     }
12
13     public Lst addLstItem(LstItem lstItem) {
14         lstItem.setLstName(name);
15         while (this.lstItems.contains(lstItem)) {
16             lstItem.incNumOfEqualItems();
17         }
18         this.lstItems.add(lstItem);
19         return this;
20     }
21
22     public Set<LstItem> getLstItems() {
23         return lstItems;
24     }
25
26     @Override
27     public boolean equals(Object obj) {
28         if (this == obj) {
29             return true;
30         }
31         if (!this.getClass().equals(obj.getClass())) {
32             return false;
33         }
34         if (!super.equals(obj)) {
35             return false;
36         }
37         Lst lst = (Lst) obj;
38         if (this.lstItems == null) {
39             if (lst.lstItems != null) {
40                 return false;
41             }
42         } else if (!this.lstItems.equals(lst.lstItems)) {
43             return false;
44         }
45         return true;
46     }
47
48     @Override
49     public int hashCode() {
50         final int prime = 31;
51         int result = super.hashCode();
52         result = prime * result + ((lstItems == null) ? 0 : lstItems.hashCode());
53         return result;
54     }
55
56 }