BUG-7464: Hide CNodeBase.csize 70/49870/6
authorRobert Varga <rovarga@cisco.com>
Fri, 30 Dec 2016 12:22:41 +0000 (13:22 +0100)
committerRobert Varga <rovarga@cisco.com>
Mon, 9 Jan 2017 14:17:12 +0000 (15:17 +0100)
This field should be accessed only through its accessor, hide it,
along with its updater.

Change-Id: I873ac0abc7d94d616e917d9c87317a55b0280747
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/CNodeBase.java

index b856547edd91e97c31fafefeff1c9426c13a6326..71279440f25f40bb10398838feada4b30816131d 100644 (file)
@@ -18,21 +18,17 @@ package org.opendaylight.yangtools.triemap;
 import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
 
 abstract class CNodeBase<K, V> extends MainNode<K, V> {
+    @SuppressWarnings("rawtypes")
+    private static final AtomicIntegerFieldUpdater<CNodeBase> CSIZE_UPDATER =
+            AtomicIntegerFieldUpdater.newUpdater(CNodeBase.class, "csize");
 
-    public static final AtomicIntegerFieldUpdater<CNodeBase> updater = AtomicIntegerFieldUpdater.newUpdater(CNodeBase.class, "csize");
+    private volatile int csize = -1;
 
-    public volatile int csize = -1;
-
-    public boolean CAS_SIZE(final int oldval, final int nval) {
-        return updater.compareAndSet(this, oldval, nval);
-    }
-
-    public void WRITE_SIZE(final int nval) {
-        updater.set(this, nval);
+    final boolean CAS_SIZE(final int oldval, final int nval) {
+        return CSIZE_UPDATER.compareAndSet(this, oldval, nval);
     }
 
-    public int READ_SIZE() {
-        return updater.get(this);
+    final int READ_SIZE() {
+        return csize;
     }
-
-}
\ No newline at end of file
+}