BUG-7464: Do not check twice for prev to be null
[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 java.util.AbstractMap.SimpleImmutableEntry;
19 import java.util.Map.Entry;
20
21 final class SNode<K, V> extends BasicNode implements KVNode<K, V> {
22     final K k;
23     final V v;
24     final int hc;
25
26     SNode(final K k, final V v, final int hc) {
27         this.k = k;
28         this.v = v;
29         this.hc = hc;
30     }
31
32     SNode<K, V> copy() {
33         return new SNode<>(k, v, hc);
34     }
35
36     TNode<K, V> copyTombed() {
37         return new TNode<>(k, v, hc);
38     }
39
40     SNode<K, V> copyUntombed() {
41         return new SNode<>(k, v, hc);
42     }
43
44     @Override
45     public Entry<K, V> kvPair() {
46         return new SimpleImmutableEntry<>(k, v);
47     }
48
49     @Override
50     String string(final int lev) {
51         // ("  " * lev) + "SNode(%s, %s, %x)".format(k, v, hc);
52         return "SNode";
53     }
54 }