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.YangInstanceIdentifier;
15 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
17 import com.google.common.base.Objects.ToStringHelper;
19 public abstract class AbstractImmutableDataContainerAttrNode<K extends YangInstanceIdentifier.PathArgument>
20 extends AbstractImmutableDataContainerNode<K>
21 implements AttributesContainer {
23 private final Map<QName, String> attributes;
25 public AbstractImmutableDataContainerAttrNode(
26 final Map<YangInstanceIdentifier.PathArgument, DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> children,
27 final K nodeIdentifier, final Map<QName, String> attributes) {
28 super(children, nodeIdentifier);
29 this.attributes = attributes;
33 public final Map<QName, String> getAttributes() {
38 public final Object getAttributeValue(final QName value) {
39 return attributes.get(value);
43 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
44 return super.addToStringAttributes(toStringHelper).add("attributes", attributes);
47 // FIXME: are attributes part of hashCode/equals?
49 // protected int valueHashCode() {
50 // int result = super.valueHashCode();
51 // for (final Entry<?, ?> a : attributes.entrySet()) {
52 // result = 31 * result + a.hashCode();
57 // FIXME: are attributes part of hashCode/equals?
59 // protected boolean valueEquals(final NormalizedNode<?, ?> other) {
60 // if (!super.valueEquals(other)) {
63 // final Set<Entry<QName, String>> tas = getAttributes().entrySet();
64 // final Set<Entry<QName, String>> oas = container.getAttributes().entrySet();
66 // return tas.containsAll(oas) && oas.containsAll(tas);