395c477b00ee90f5869bda1a0bb8e616eb8aebee
[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 final class SNode<K, V> extends BasicNode implements EntryNode<K, V> {
19     final K k;
20     final V v;
21     final int hc;
22
23     SNode(final K k, final V v, final int hc) {
24         this.k = k;
25         this.v = v;
26         this.hc = hc;
27     }
28
29     SNode<K, V> copy() {
30         return new SNode<>(k, v, hc);
31     }
32
33     TNode<K, V> copyTombed() {
34         return new TNode<>(k, v, hc);
35     }
36
37     SNode<K, V> copyUntombed() {
38         return new SNode<>(k, v, hc);
39     }
40
41     @Override
42     String string(final int lev) {
43         // ("  " * lev) + "SNode(%s, %s, %x)".format(k, v, hc);
44         return "SNode";
45     }
46
47     @Override
48     public K getKey() {
49         return k;
50     }
51
52     @Override
53     public V getValue() {
54         return v;
55     }
56
57     @Override
58     public int hashCode() {
59         return EntryUtil.hash(k, v);
60     }
61
62     @Override
63     public boolean equals(final Object o) {
64         return EntryUtil.equal(o, k, v);
65     }
66
67     @Override
68     public String toString() {
69         return EntryUtil.string(k, v);
70     }
71 }