Merge "Remove unused imports"
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / CompositeNodeTOImpl.java
index 4f0b3a524247681974d1d1a572e02643ff0524ce..3e59659d2e106eb397ef5fefa429df967ba7baa4 100644 (file)
@@ -7,13 +7,6 @@
  */
 package org.opendaylight.yangtools.yang.data.impl;
 
-import org.opendaylight.yangtools.yang.common.QName;
-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 java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
@@ -26,10 +19,20 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.opendaylight.yangtools.yang.common.QName;
+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;
+
 /**
  * @author michal.rehak
- * 
+ *
+ * @deprecated Use one of the {@link NormalizedNodeContainer} implementations.
  */
+@Deprecated
 public class CompositeNodeTOImpl extends AbstractNodeTO<List<Node<?>>> implements CompositeNode, Serializable {
 
     private static final long serialVersionUID = 100L;
@@ -42,7 +45,7 @@ public class CompositeNodeTOImpl extends AbstractNodeTO<List<Node<?>>> implement
      *            use null to create top composite node (without parent)
      * @param value
      */
-    public CompositeNodeTOImpl(QName qname, CompositeNode parent, List<Node<?>> value) {
+    public CompositeNodeTOImpl(final QName qname, final CompositeNode parent, final List<Node<?>> value) {
         super(qname, parent, value);
         init();
     }
@@ -54,11 +57,11 @@ public class CompositeNodeTOImpl extends AbstractNodeTO<List<Node<?>>> implement
      * @param value
      * @param modifyAction
      */
-    public CompositeNodeTOImpl(QName qname, CompositeNode parent, List<Node<?>> value, ModifyAction modifyAction) {
+    public CompositeNodeTOImpl(final QName qname, final CompositeNode parent, final List<Node<?>> value, final ModifyAction modifyAction) {
         super(qname, parent, value, modifyAction);
         init();
     }
-    
+
     protected void init() {
         if (getValue() != null) {
             nodeMap = NodeUtils.buildNodeMap(getValue());
@@ -75,7 +78,7 @@ public class CompositeNodeTOImpl extends AbstractNodeTO<List<Node<?>>> implement
     }
 
     @Override
-    public SimpleNode<?> getFirstSimpleByName(QName leafQName) {
+    public SimpleNode<?> getFirstSimpleByName(final QName leafQName) {
         List<SimpleNode<?>> list = getSimpleNodesByName(leafQName);
         if (list.isEmpty()) {
             return null;
@@ -84,7 +87,7 @@ public class CompositeNodeTOImpl extends AbstractNodeTO<List<Node<?>>> implement
     }
 
     @Override
-    public List<CompositeNode> getCompositesByName(QName children) {
+    public List<CompositeNode> getCompositesByName(final QName children) {
         List<Node<?>> toFilter = getNodeMap().get(children);
         if(toFilter == null) {
             return Collections.emptyList();
@@ -99,7 +102,7 @@ public class CompositeNodeTOImpl extends AbstractNodeTO<List<Node<?>>> implement
     }
 
     @Override
-    public List<SimpleNode<?>> getSimpleNodesByName(QName children) {
+    public List<SimpleNode<?>> getSimpleNodesByName(final QName children) {
         List<Node<?>> toFilter = getNodeMap().get(children);
         if(toFilter == null) {
             return Collections.emptyList();
@@ -115,7 +118,7 @@ public class CompositeNodeTOImpl extends AbstractNodeTO<List<Node<?>>> implement
     }
 
     @Override
-    public CompositeNode getFirstCompositeByName(QName container) {
+    public CompositeNode getFirstCompositeByName(final QName container) {
         List<CompositeNode> list = getCompositesByName(container);
         if (list.isEmpty()) {
             return null;
@@ -127,7 +130,7 @@ public class CompositeNodeTOImpl extends AbstractNodeTO<List<Node<?>>> implement
      * @param leaf
      * @return TODO:: do we need this method?
      */
-    public SimpleNode<?> getFirstLeafByName(QName leaf) {
+    public SimpleNode<?> getFirstLeafByName(final QName leaf) {
         List<SimpleNode<?>> list = getSimpleNodesByName(leaf);
         if (list.isEmpty()) {
             return null;
@@ -136,13 +139,13 @@ public class CompositeNodeTOImpl extends AbstractNodeTO<List<Node<?>>> implement
     }
 
     @Override
-    public List<CompositeNode> getCompositesByName(String children) {
-        return getCompositesByName(new QName(getNodeType(), children));
+    public List<CompositeNode> getCompositesByName(final String children) {
+        return getCompositesByName(QName.create(getNodeType(), children));
     }
 
     @Override
-    public List<SimpleNode<?>> getSimpleNodesByName(String children) {
-        return getSimpleNodesByName(new QName(getNodeType(), children));
+    public List<SimpleNode<?>> getSimpleNodesByName(final String children) {
+        return getSimpleNodesByName(QName.create(getNodeType(), children));
     }
 
     @Override
@@ -152,33 +155,28 @@ public class CompositeNodeTOImpl extends AbstractNodeTO<List<Node<?>>> implement
 
     @Override
     public String toString() {
-        return super.toString() + ", children.size = " + (getChildren() != null ? getChildren().size() : "n/a");
+        return super.toString() + ", children.size = " + (!getChildren().isEmpty() ? getChildren().size() : "n/a");
     }
-    
+
     @Override
     public void clear() {
         nodeMap.clear();
     }
-    
+
     @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);
     }
-    
+
     @Override
     public Set<java.util.Map.Entry<QName, List<Node<?>>>> entrySet() {
         return nodeMap.entrySet();
     }
-    
-    @Override
-    public boolean equals(Object obj) {
-        return super.equals(obj);
-    }
 
     @Override
     public int size() {
@@ -191,22 +189,22 @@ public class CompositeNodeTOImpl extends AbstractNodeTO<List<Node<?>>> implement
     }
 
     @Override
-    public List<Node<?>> get(Object key) {
+    public List<Node<?>> get(final Object key) {
         return nodeMap.get(key);
     }
 
     @Override
-    public List<Node<?>> put(QName key, List<Node<?>> value) {
+    public List<Node<?>> put(final QName key, final List<Node<?>> value) {
         return nodeMap.put(key, value);
     }
 
     @Override
-    public List<Node<?>> remove(Object key) {
+    public List<Node<?>> remove(final Object key) {
         return nodeMap.remove(key);
     }
 
     @Override
-    public void putAll(Map<? extends QName, ? extends List<Node<?>>> m) {
+    public void putAll(final Map<? extends QName, ? extends List<Node<?>>> m) {
         nodeMap.putAll(m);
     }
 
@@ -220,19 +218,20 @@ public class CompositeNodeTOImpl extends AbstractNodeTO<List<Node<?>>> implement
         return nodeMap.values();
     }
 
-  // Serialization related
+    // 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<Node<?>> value = (List<Node<?>>) 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());