Hide UniqueValidator methods 02/93902/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 20 Nov 2020 15:54:59 +0000 (16:54 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 20 Nov 2020 16:56:46 +0000 (17:56 +0100)
Our contract is quite crisp, make sure we hide static utility
methods.

JIRA: YANGTOOLS-1177
Change-Id: I9718b7a05cc44906d710a93beaaddd8c12ae93bf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit b5b5f129a8e81f47f45ee09cc22c62e3fd05904a)

yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/UniqueValidator.java

index b7aeae16244f02424ca5bc3df18f45bac6b81640..68f4af7c42a6d4cf4cee60a5fa88f0f03f8de0db 100644 (file)
@@ -16,6 +16,7 @@ import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Maps;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
@@ -112,6 +113,11 @@ abstract class UniqueValidator<T> implements Immutable {
      */
     abstract Map<Descendant, @Nullable Object> indexValues(Object values);
 
+    @Override
+    public final String toString() {
+        return MoreObjects.toStringHelper(this).add("paths", descendants).toString();
+    }
+
     /**
      * Encode a path for storage. Single-element paths are squashed to their only element. The inverse operation is
      * {@link #decodePath(Object)}.
@@ -119,7 +125,9 @@ abstract class UniqueValidator<T> implements Immutable {
      * @param path Path to encode
      * @return Encoded path.
      */
-    static final Object encodePath(final List<NodeIdentifier> path) {
+    @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+        justification = "https://github.com/spotbugs/spotbugs/issues/811")
+    private static Object encodePath(final List<NodeIdentifier> path) {
         return path.size() == 1 ? path.get(0) : ImmutableList.copyOf(path);
     }
 
@@ -129,12 +137,14 @@ abstract class UniqueValidator<T> implements Immutable {
      * @param obj Encoded path
      * @return Decoded path
      */
-    static final @NonNull ImmutableList<NodeIdentifier> decodePath(final Object obj) {
+    private static @NonNull ImmutableList<NodeIdentifier> decodePath(final Object obj) {
         return obj instanceof NodeIdentifier ? ImmutableList.of((NodeIdentifier) obj)
             : (ImmutableList<NodeIdentifier>) obj;
     }
 
-    static final @NonNull Descendant decodeDescendant(final Object obj) {
+    @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+        justification = "https://github.com/spotbugs/spotbugs/issues/811")
+    private static @NonNull Descendant decodeDescendant(final Object obj) {
         return Descendant.of(Collections2.transform(decodePath(obj), NodeIdentifier::getNodeType));
     }
 
@@ -146,7 +156,9 @@ abstract class UniqueValidator<T> implements Immutable {
      * @param path Descendant path
      * @return Value for the descendant
      */
-    static final @Nullable Object extractValue(final Map<List<NodeIdentifier>, Object> valueCache,
+    @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+        justification = "https://github.com/spotbugs/spotbugs/issues/811")
+    private static @Nullable Object extractValue(final Map<List<NodeIdentifier>, Object> valueCache,
             final DataContainerNode<?> data, final List<NodeIdentifier> path) {
         return valueCache.computeIfAbsent(path, key -> extractValue(data, key));
     }
@@ -180,9 +192,4 @@ abstract class UniqueValidator<T> implements Immutable {
             current = (DataContainerNode<?>) next;
         }
     }
-
-    @Override
-    public final String toString() {
-        return MoreObjects.toStringHelper(this).add("paths", descendants).toString();
-    }
 }