X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-data-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fdata%2Fimpl%2FImmutableCompositeNode.java;h=1d56fd660104b4cdb6fef0b244194e0380d49b29;hb=d92046aedb1644cfd7d5b0ad20a76764e9bc04ea;hp=de90279fd9f525cb3ea9e57bc8e30e865927a277;hpb=dd2edcd83da73c13333e496c7ae9aa59a5111d15;p=yangtools.git diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/ImmutableCompositeNode.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/ImmutableCompositeNode.java index de90279fd9..1d56fd6601 100644 --- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/ImmutableCompositeNode.java +++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/ImmutableCompositeNode.java @@ -7,12 +7,6 @@ */ package org.opendaylight.yangtools.yang.data.impl; -import org.opendaylight.yangtools.concepts.Immutable; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.*; -import org.opendaylight.yangtools.yang.data.api.ModifyAction; -import org.opendaylight.yangtools.yang.data.impl.util.AbstractCompositeNodeBuilder; -import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -28,11 +22,23 @@ import java.util.List; import java.util.Map; import java.util.Set; -public final class ImmutableCompositeNode extends AbstractNodeTO>> implements // - Immutable, // - CompositeNode, // - AttributesContainer, // - Serializable { +import org.opendaylight.yangtools.concepts.Immutable; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.AttributesContainer; +import org.opendaylight.yangtools.yang.data.api.CompositeNode; +import org.opendaylight.yangtools.yang.data.api.ModifyAction; +import org.opendaylight.yangtools.yang.data.api.MutableCompositeNode; +import org.opendaylight.yangtools.yang.data.api.Node; +import org.opendaylight.yangtools.yang.data.api.SimpleNode; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer; +import org.opendaylight.yangtools.yang.data.impl.util.AbstractCompositeNodeBuilder; +import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder; + +/** + * @deprecated Use one of the {@link NormalizedNodeContainer} implementations. + */ +@Deprecated +public final class ImmutableCompositeNode extends AbstractNodeTO>> implements Immutable, CompositeNode, AttributesContainer, Serializable { private static final long serialVersionUID = 100L; @@ -48,7 +54,7 @@ public final class ImmutableCompositeNode extends AbstractNodeTO>> * use null to create top composite node (without parent) * @param value */ - private ImmutableCompositeNode(QName qname, Map attributes,List> value) { + private ImmutableCompositeNode(final QName qname, final Map attributes,final List> value) { super(qname, null, ImmutableList.copyOf(value)); if(attributes == null) { this.attributes = ImmutableMap.of(); @@ -58,18 +64,6 @@ public final class ImmutableCompositeNode extends AbstractNodeTO>> init(); } - /** - * @param qname - * @param parent - * use null to create top composite node (without parent) - * @param value - */ - private ImmutableCompositeNode(QName qname, List> value, QName a1, String av) { - super(qname, null, value); - attributes = ImmutableMap.of(a1, av); - init(); - } - /** * @param qname * @param parent @@ -77,7 +71,7 @@ public final class ImmutableCompositeNode extends AbstractNodeTO>> * @param value * @param modifyAction */ - public ImmutableCompositeNode(QName qname, List> value, ModifyAction modifyAction) { + public ImmutableCompositeNode(final QName qname, final List> value, final ModifyAction modifyAction) { super(qname, null, value, modifyAction); attributes = ImmutableMap.of(); init(); @@ -99,7 +93,7 @@ public final class ImmutableCompositeNode extends AbstractNodeTO>> } @Override - public SimpleNode getFirstSimpleByName(QName leafQName) { + public SimpleNode getFirstSimpleByName(final QName leafQName) { List> list = getSimpleNodesByName(leafQName); if (list.isEmpty()) { return null; @@ -108,7 +102,7 @@ public final class ImmutableCompositeNode extends AbstractNodeTO>> } @Override - public List getCompositesByName(QName children) { + public List getCompositesByName(final QName children) { List> toFilter = getNodeMap().get(children); if (toFilter == null) { return Collections.emptyList(); @@ -123,7 +117,7 @@ public final class ImmutableCompositeNode extends AbstractNodeTO>> } @Override - public List> getSimpleNodesByName(QName children) { + public List> getSimpleNodesByName(final QName children) { List> toFilter = getNodeMap().get(children); if (toFilter == null) { return Collections.emptyList(); @@ -139,7 +133,7 @@ public final class ImmutableCompositeNode extends AbstractNodeTO>> } @Override - public CompositeNode getFirstCompositeByName(QName container) { + public CompositeNode getFirstCompositeByName(final QName container) { List list = getCompositesByName(container); if (list.isEmpty()) { return null; @@ -153,7 +147,7 @@ public final class ImmutableCompositeNode extends AbstractNodeTO>> } @Override - public String getAttributeValue(QName key) { + public String getAttributeValue(final QName key) { return attributes.get(key); } @@ -161,7 +155,7 @@ public final class ImmutableCompositeNode extends AbstractNodeTO>> * @param leaf * @return TODO:: do we need this method? */ - public SimpleNode getFirstLeafByName(QName leaf) { + public SimpleNode getFirstLeafByName(final QName leaf) { List> list = getSimpleNodesByName(leaf); if (list.isEmpty()) { return null; @@ -170,13 +164,13 @@ public final class ImmutableCompositeNode extends AbstractNodeTO>> } @Override - public List getCompositesByName(String children) { - return getCompositesByName(new QName(getNodeType(), children)); + public List getCompositesByName(final String children) { + return getCompositesByName(QName.create(getNodeType(), children)); } @Override - public List> getSimpleNodesByName(String children) { - return getSimpleNodesByName(new QName(getNodeType(), children)); + public List> getSimpleNodesByName(final String children) { + return getSimpleNodesByName(QName.create(getNodeType(), children)); } @Override @@ -195,12 +189,12 @@ public final class ImmutableCompositeNode extends AbstractNodeTO>> } @Override - public boolean containsKey(Object key) { + public boolean containsKey(final Object key) { return nodeMap.containsKey(key); } @Override - public boolean containsValue(Object value) { + public boolean containsValue(final Object value) { return nodeMap.containsValue(value); } @@ -209,11 +203,6 @@ public final class ImmutableCompositeNode extends AbstractNodeTO>> return nodeMap.entrySet(); } - @Override - public boolean equals(Object obj) { - return super.equals(obj); - } - @Override public int size() { return nodeMap.size(); @@ -225,22 +214,22 @@ public final class ImmutableCompositeNode extends AbstractNodeTO>> } @Override - public List> get(Object key) { + public List> get(final Object key) { return nodeMap.get(key); } @Override - public List> put(QName key, List> value) { + public List> put(final QName key, final List> value) { return nodeMap.put(key, value); } @Override - public List> remove(Object key) { + public List> remove(final Object key) { return nodeMap.remove(key); } @Override - public void putAll(Map>> m) { + public void putAll(final Map>> m) { nodeMap.putAll(m); } @@ -256,17 +245,18 @@ public final class ImmutableCompositeNode extends AbstractNodeTO>> // Serialization related - private void readObject(ObjectInputStream aStream) throws IOException, ClassNotFoundException { + private void readObject(final ObjectInputStream aStream) throws IOException, ClassNotFoundException { aStream.defaultReadObject(); QName qName = (QName) aStream.readObject(); CompositeNode parent = (CompositeNode) aStream.readObject(); + @SuppressWarnings("unchecked") List> value = (List>) aStream.readObject(); ModifyAction modifyAction = (ModifyAction) aStream.readObject(); init(qName, parent, value, modifyAction); } - private void writeObject(ObjectOutputStream aStream) throws IOException { + private void writeObject(final ObjectOutputStream aStream) throws IOException { aStream.defaultWriteObject(); // manually serialize superclass aStream.writeObject(getQName()); @@ -282,7 +272,7 @@ public final class ImmutableCompositeNode extends AbstractNodeTO>> private static class ImmutableCompositeNodeBuilder extends AbstractCompositeNodeBuilder { @Override - public AbstractCompositeNodeBuilder addLeaf(QName leafName, Object leafValue) { + public AbstractCompositeNodeBuilder addLeaf(final QName leafName, final Object leafValue) { add(new SimpleNodeTOImpl(leafName, null, leafValue)); return this; } @@ -294,15 +284,15 @@ public final class ImmutableCompositeNode extends AbstractNodeTO>> } - public static ImmutableCompositeNode create(QName qName, List> childNodes) { + public static ImmutableCompositeNode create(final QName qName, final List> childNodes) { return new ImmutableCompositeNode(qName, ImmutableMap.of(),childNodes); } - public static ImmutableCompositeNode create(QName qName, Map attributes, List> childNodes) { + public static ImmutableCompositeNode create(final QName qName, final Map attributes, final List> childNodes) { return new ImmutableCompositeNode(qName, attributes,childNodes); } - public static ImmutableCompositeNode create(QName qName, List> childNodes, ModifyAction modifyAction) { + public static ImmutableCompositeNode create(final QName qName, final List> childNodes, final ModifyAction modifyAction) { return new ImmutableCompositeNode(qName, childNodes, modifyAction); } }