7b1fb773fd57c2239e3b0191fcd4b33fe2d1a6d8
[yangtools.git] / third-party / triemap / src / main / java / org / opendaylight / yangtools / triemap / SNode.java
1 /*
2  * (C) Copyright 2016 Pantheon Technologies, s.r.o. and others.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.opendaylight.yangtools.triemap;
17
18 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
19
20 final class SNode<K, V> extends BasicNode implements EntryNode<K, V> {
21     final K k;
22     final V v;
23     final int hc;
24
25     SNode(final K k, final V v, final int hc) {
26         this.k = k;
27         this.v = v;
28         this.hc = hc;
29     }
30
31     SNode<K, V> copy() {
32         return new SNode<>(k, v, hc);
33     }
34
35     TNode<K, V> copyTombed() {
36         return new TNode<>(k, v, hc);
37     }
38
39     SNode<K, V> copyUntombed() {
40         return new SNode<>(k, v, hc);
41     }
42
43     @Override
44     String string(final int lev) {
45         // ("  " * lev) + "SNode(%s, %s, %x)".format(k, v, hc);
46         return "SNode";
47     }
48
49     @Override
50     public K getKey() {
51         return k;
52     }
53
54     @Override
55     public V getValue() {
56         return v;
57     }
58
59     @Override
60     public int hashCode() {
61         return EntryUtil.hash(k, v);
62     }
63
64     @SuppressFBWarnings(value = "EQ_UNUSUAL",  justification = "Equality handled by utility methods")
65     @Override
66     public boolean equals(final Object o) {
67         return EntryUtil.equal(o, k, v);
68     }
69
70     @Override
71     public String toString() {
72         return EntryUtil.string(k, v);
73     }
74 }