*/
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;
import java.util.Map;
import java.util.Set;
+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.impl.util.AbstractCompositeNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder;
+
public final class ImmutableCompositeNode extends AbstractNodeTO<List<Node<?>>> implements //
- Immutable, //
- CompositeNode, //
- AttributesContainer, //
- Serializable {
+Immutable, //
+CompositeNode, //
+AttributesContainer, //
+Serializable {
private static final long serialVersionUID = 100L;
* use null to create top composite node (without parent)
* @param value
*/
- private ImmutableCompositeNode(QName qname, Map<QName,String> attributes,List<Node<?>> value) {
+ private ImmutableCompositeNode(final QName qname, final Map<QName,String> attributes,final List<Node<?>> value) {
super(qname, null, ImmutableList.copyOf(value));
if(attributes == null) {
this.attributes = ImmutableMap.<QName, String>of();
init();
}
- /**
- * @param qname
- * @param parent
- * use null to create top composite node (without parent)
- * @param value
- */
- private ImmutableCompositeNode(QName qname, List<Node<?>> value, QName a1, String av) {
- super(qname, null, value);
- attributes = ImmutableMap.of(a1, av);
- init();
- }
-
/**
* @param qname
* @param parent
* @param value
* @param modifyAction
*/
- public ImmutableCompositeNode(QName qname, List<Node<?>> value, ModifyAction modifyAction) {
+ public ImmutableCompositeNode(final QName qname, final List<Node<?>> value, final ModifyAction modifyAction) {
super(qname, null, value, modifyAction);
attributes = ImmutableMap.of();
init();
}
@Override
- public SimpleNode<?> getFirstSimpleByName(QName leafQName) {
+ public SimpleNode<?> getFirstSimpleByName(final QName leafQName) {
List<SimpleNode<?>> list = getSimpleNodesByName(leafQName);
if (list.isEmpty()) {
return null;
}
@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();
}
@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();
}
@Override
- public CompositeNode getFirstCompositeByName(QName container) {
+ public CompositeNode getFirstCompositeByName(final QName container) {
List<CompositeNode> list = getCompositesByName(container);
if (list.isEmpty()) {
return null;
}
@Override
- public String getAttributeValue(QName key) {
+ public String getAttributeValue(final QName key) {
return attributes.get(key);
}
* @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;
}
@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
}
@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);
}
return nodeMap.entrySet();
}
- @Override
- public boolean equals(Object obj) {
- return super.equals(obj);
- }
-
@Override
public int size() {
return nodeMap.size();
}
@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);
}
// 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());
private static class ImmutableCompositeNodeBuilder extends AbstractCompositeNodeBuilder<ImmutableCompositeNode> {
@Override
- public AbstractCompositeNodeBuilder<ImmutableCompositeNode> addLeaf(QName leafName, Object leafValue) {
+ public AbstractCompositeNodeBuilder<ImmutableCompositeNode> addLeaf(final QName leafName, final Object leafValue) {
add(new SimpleNodeTOImpl<Object>(leafName, null, leafValue));
return this;
}
}
- public static ImmutableCompositeNode create(QName qName, List<Node<?>> childNodes) {
+ public static ImmutableCompositeNode create(final QName qName, final List<Node<?>> childNodes) {
return new ImmutableCompositeNode(qName, ImmutableMap.<QName, String>of(),childNodes);
}
- public static ImmutableCompositeNode create(QName qName, Map<QName, String> attributes, List<Node<?>> childNodes) {
+ public static ImmutableCompositeNode create(final QName qName, final Map<QName, String> attributes, final List<Node<?>> childNodes) {
return new ImmutableCompositeNode(qName, attributes,childNodes);
}
- public static ImmutableCompositeNode create(QName qName, List<Node<?>> childNodes, ModifyAction modifyAction) {
+ public static ImmutableCompositeNode create(final QName qName, final List<Node<?>> childNodes, final ModifyAction modifyAction) {
return new ImmutableCompositeNode(qName, childNodes, modifyAction);
}
}