2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.data.impl.schema.nodes;
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.data.api.AttributesContainer;
14 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
16 import com.google.common.base.Objects.ToStringHelper;
17 import com.google.common.collect.ImmutableMap;
19 public abstract class AbstractImmutableNormalizedAttrNode<K extends InstanceIdentifier.PathArgument,V>
20 extends AbstractImmutableNormalizedNode<K, V>
21 implements AttributesContainer {
23 private final Map<QName, String> attributes;
25 protected AbstractImmutableNormalizedAttrNode(final K nodeIdentifier, final V value, final Map<QName, String> attributes) {
26 super(nodeIdentifier, value);
27 this.attributes = ImmutableMap.copyOf(attributes);
31 public final Map<QName, String> getAttributes() {
36 public final Object getAttributeValue(final QName value) {
37 return attributes.get(value);
41 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
42 return super.addToStringAttributes(toStringHelper).add("attributes", attributes);
46 protected int valueHashCode() {
47 final int result = getValue().hashCode();
48 // FIXME: are attributes part of hashCode/equals?
49 // for (final Entry<?, ?> a : attributes.entrySet()) {
50 // result = 31 * result + a.hashCode();
56 protected boolean valueEquals(final AbstractImmutableNormalizedNode<?, ?> other) {
57 if (!getValue().equals(other.getValue())) {
61 // FIXME: are attributes part of hashCode/equals?
62 // final Set<Entry<QName, String>> tas = getAttributes().entrySet();
63 // final Set<Entry<QName, String>> oas = container.getAttributes().entrySet();
65 // return tas.containsAll(oas) && oas.containsAll(tas);