Merge branch 'master' of ../controller
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / nodes / AbstractImmutableNormalizedSimpleValueNode.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.data.impl.schema.nodes;
9
10 import java.util.Objects;
11 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
12
13 public abstract class AbstractImmutableNormalizedSimpleValueNode<K extends PathArgument,V>
14         extends AbstractImmutableNormalizedValueNode<K, V> {
15     protected AbstractImmutableNormalizedSimpleValueNode(final K nodeIdentifier, final V value) {
16         super(nodeIdentifier, value);
17     }
18
19     @Override
20     protected int valueHashCode() {
21         final V local = value();
22         final int result = local != null ? local.hashCode() : 1;
23         // FIXME: are attributes part of hashCode/equals?
24         return result;
25     }
26
27     @Override
28     protected boolean valueEquals(final AbstractImmutableNormalizedNode<?, ?> other) {
29         // We can not call directly getValue.equals because of Empty Type
30         // RequireInstanceStatementSupport leaves which always have NULL value
31
32         // FIXME: are attributes part of hashCode/equals?
33         return Objects.deepEquals(value(), other.getValue());
34     }
35 }