/* * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.controller.sal.restconf.impl.test.structures; import java.util.HashSet; import java.util.Set; public class Lst extends YangElement { private final Set lstItems; public Lst(final String name) { super(name); lstItems = new HashSet<>(); } public Lst addLstItem(final LstItem lstItem) { lstItem.setLstName(name); while (this.lstItems.contains(lstItem)) { lstItem.incNumOfEqualItems(); } this.lstItems.add(lstItem); return this; } public Set getLstItems() { return lstItems; } @Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (!this.getClass().equals(obj.getClass())) { return false; } if (!super.equals(obj)) { return false; } Lst lst = (Lst) obj; if (this.lstItems == null) { if (lst.lstItems != null) { return false; } } else if (!this.lstItems.equals(lst.lstItems)) { return false; } return true; } @Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((lstItems == null) ? 0 : lstItems.hashCode()); return result; } }