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;
10 import org.opendaylight.yangtools.concepts.Immutable;
11 import org.opendaylight.yangtools.yang.common.QName;
12 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
13 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
14 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
16 import com.google.common.base.Objects;
17 import com.google.common.base.Preconditions;
19 public abstract class AbstractImmutableNormalizedNode<K extends InstanceIdentifier.PathArgument,V>
20 implements NormalizedNode<K, V>, Immutable {
22 protected final K nodeIdentifier;
23 protected final V value;
25 protected AbstractImmutableNormalizedNode(K nodeIdentifier, V value) {
26 this.nodeIdentifier = Preconditions.checkNotNull(nodeIdentifier, "nodeIdentifier");
27 this.value = Preconditions.checkNotNull(value, "value");
31 public final QName getNodeType() {
32 return getIdentifier().getNodeType();
36 public final K getIdentifier() {
37 return nodeIdentifier;
41 public final CompositeNode getParent() {
42 throw new UnsupportedOperationException("Deprecated");
46 public final QName getKey() {
51 public final V getValue() {
56 public final V setValue(V value) {
57 throw new UnsupportedOperationException("Immutable");
61 public final String toString() {
62 return Objects.toStringHelper(this)
63 .add("nodeIdentifier", nodeIdentifier)
69 public boolean equals(Object o) {
70 if (this == o) return true;
71 if (!(o instanceof AbstractImmutableNormalizedNode)) return false;
73 AbstractImmutableNormalizedNode<?, ?> that = (AbstractImmutableNormalizedNode<?, ?>) o;
75 if (!nodeIdentifier.equals(that.nodeIdentifier)) return false;
76 if (!value.equals(that.value)) return false;
82 public int hashCode() {
83 int result = nodeIdentifier.hashCode();
84 result = 31 * result + value.hashCode();