X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fsal%2Fyang-prototype%2Fyang%2Fyang-data-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fdata%2Futil%2FAbstractContainerNode.java;fp=opendaylight%2Fsal%2Fyang-prototype%2Fyang%2Fyang-data-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fdata%2Futil%2FAbstractContainerNode.java;h=0000000000000000000000000000000000000000;hb=4ce0f6630bc576b97c8c9a08848aafb6e90a75b0;hp=7a5cfda6de1e5eb444632abc411f94f87648bad8;hpb=c8b79431119d6952b60a092e89727aa648a89bdd;p=controller.git diff --git a/opendaylight/sal/yang-prototype/yang/yang-data-util/src/main/java/org/opendaylight/controller/data/util/AbstractContainerNode.java b/opendaylight/sal/yang-prototype/yang/yang-data-util/src/main/java/org/opendaylight/controller/data/util/AbstractContainerNode.java deleted file mode 100644 index 7a5cfda6de..0000000000 --- a/opendaylight/sal/yang-prototype/yang/yang-data-util/src/main/java/org/opendaylight/controller/data/util/AbstractContainerNode.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2013 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.data.util; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import org.opendaylight.controller.yang.common.QName; -import org.opendaylight.controller.yang.data.api.CompositeNode; -import org.opendaylight.controller.yang.data.api.Node; -import org.opendaylight.controller.yang.data.api.SimpleNode; - -public abstract class AbstractContainerNode extends AbstractNode>> - implements CompositeNode { - - public SimpleNode getFirstSimpleByName(QName leaf) { - List> list = getSimpleNodesByName(leaf); - if (list.size() == 0) - return null; - return list.get(0); - } - - protected AbstractContainerNode(QName name, CompositeNode parent) { - super(name, parent); - } - - public AbstractContainerNode(QName name) { - super(name, null); - } - - public List> getChildren() { - return getValue(); - } - - public List> getValue() { - Map>> map = getNodeMap(); - if (map == null) - throw new IllegalStateException("nodeMap should not be null"); - List> ret = new ArrayList>(); - Collection>> values = map.values(); - for (List> list : values) { - ret.addAll(list); - } - return ret; - } - - protected abstract Map>> getNodeMap(); - - public List getCompositesByName(QName children) { - Map>> map = getNodeMap(); - if (map == null) - throw new IllegalStateException("nodeMap should not be null"); - List> toFilter = map.get(children); - List list = new ArrayList(); - for (Node node : toFilter) { - if (node instanceof CompositeNode) - list.add((CompositeNode) node); - } - return list; - } - - public List> getSimpleNodesByName(QName children) { - Map>> map = getNodeMap(); - if (map == null) - throw new IllegalStateException("nodeMap should not be null"); - List> toFilter = map.get(children); - List> list = new ArrayList>(); - - for (Node node : toFilter) { - if (node instanceof SimpleNode) - list.add((SimpleNode) node); - } - return list; - } - - public CompositeNode getFirstCompositeByName(QName container) { - List list = getCompositesByName(container); - if (list.size() == 0) - return null; - return list.get(0); - } - - public SimpleNode getFirstLeafByName(QName leaf) { - List> list = getSimpleNodesByName(leaf); - if (list.size() == 0) - return null; - return list.get(0); - } - - public List getCompositesByName(String children) { - return getCompositesByName(localQName(children)); - } - - public List> getSimpleNodesByName(String children) { - return getSimpleNodesByName(localQName(children)); - } - - private QName localQName(String str) { - return new QName(getNodeType(), str); - } -}