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 com.google.common.base.MoreObjects.ToStringHelper;
11 import org.opendaylight.yangtools.concepts.AbstractSimpleIdentifiable;
12 import org.opendaylight.yangtools.concepts.Immutable;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
17 public abstract class AbstractImmutableNormalizedNode<K extends PathArgument, V> extends AbstractSimpleIdentifiable<K>
18 implements NormalizedNode<K, V>, Immutable {
19 protected AbstractImmutableNormalizedNode(final K nodeIdentifier) {
20 super(nodeIdentifier);
24 public final QName getNodeType() {
25 return getIdentifier().getNodeType();
29 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
30 return super.addToStringAttributes(toStringHelper).add("value", getValue());
33 protected abstract boolean valueEquals(AbstractImmutableNormalizedNode<?, ?> other);
35 protected abstract int valueHashCode();
38 public final boolean equals(final Object obj) {
42 if (obj == null || this.getClass() != obj.getClass()) {
46 final AbstractImmutableNormalizedNode<?, ?> other = (AbstractImmutableNormalizedNode<?, ?>)obj;
47 return getIdentifier().equals(other.getIdentifier()) && valueEquals(other);
51 public final int hashCode() {
52 return 31 * getIdentifier().hashCode() + valueHashCode();