BUG-648: Fixup hashCode/equals
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / nodes / AbstractImmutableDataContainerAttrNode.java
index 68024d6ea292dc1c7635139dded6dc9e29f3a605..85d4a8ed7a2f5525c4212c494a6727a64bdd316d 100644 (file)
@@ -14,6 +14,8 @@ import org.opendaylight.yangtools.yang.data.api.AttributesContainer;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 
+import com.google.common.base.Objects.ToStringHelper;
+
 public abstract class AbstractImmutableDataContainerAttrNode<K extends InstanceIdentifier.PathArgument>
         extends AbstractImmutableDataContainerNode<K>
     implements AttributesContainer {
@@ -21,8 +23,8 @@ public abstract class AbstractImmutableDataContainerAttrNode<K extends InstanceI
     private final Map<QName, String> attributes;
 
     public AbstractImmutableDataContainerAttrNode(
-            Map<InstanceIdentifier.PathArgument, DataContainerChild<? extends InstanceIdentifier.PathArgument, ?>> children,
-            K nodeIdentifier, Map<QName, String> attributes) {
+            final Map<InstanceIdentifier.PathArgument, DataContainerChild<? extends InstanceIdentifier.PathArgument, ?>> children,
+            final K nodeIdentifier, final Map<QName, String> attributes) {
         super(children, nodeIdentifier);
         this.attributes = attributes;
     }
@@ -33,7 +35,35 @@ public abstract class AbstractImmutableDataContainerAttrNode<K extends InstanceI
     }
 
     @Override
-    public final Object getAttributeValue(QName value) {
+    public final Object getAttributeValue(final QName value) {
         return attributes.get(value);
     }
+
+    @Override
+    protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
+        return super.addToStringAttributes(toStringHelper).add("attributes", attributes);
+    }
+
+// FIXME: are attributes part of hashCode/equals?
+//    @Override
+//    protected int valueHashCode() {
+//        int result = super.valueHashCode();
+//        for (final Entry<?, ?> a : attributes.entrySet()) {
+//            result = 31 * result + a.hashCode();
+//        }
+//        return result;
+//    }
+
+ // FIXME: are attributes part of hashCode/equals?
+//    @Override
+//    protected boolean valueEquals(final NormalizedNode<?, ?> other) {
+//        if (!super.valueEquals(other)) {
+//            return false;
+//        }
+//        final Set<Entry<QName, String>> tas = getAttributes().entrySet();
+//        final Set<Entry<QName, String>> oas = container.getAttributes().entrySet();
+//
+//        return tas.containsAll(oas) && oas.containsAll(tas);
+//        return true;
+//    }
 }