Eliminate HelperMethods 01/101201/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 17 May 2022 22:46:34 +0000 (00:46 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 17 May 2022 23:02:06 +0000 (01:02 +0200)
The only caller is DataNodeContainer. Since Java 9 allows interfaces
to define private methods, move the methods there.

Change-Id: If4316f0a41ee8cfeced2bcb85534b5b46faaa43d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/DataNodeContainer.java
model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/HelperMethods.java [deleted file]

index 8d44da96c25bb8be5035d8ad54901e81c9c307c4..27d3f18fed3552a41f87cc3a995288ecdcf2194a 100644 (file)
@@ -147,7 +147,7 @@ public interface DataNodeContainer {
     default Optional<DataSchemaNode> findDataTreeChild(final QName name) {
         // First we try to find a direct child and check if it is a data node (as per RFC7950)
         final Optional<DataSchemaNode> optDataChild = findDataChildByName(name);
-        if (HelperMethods.isDataNode(optDataChild)) {
+        if (isDataNode(optDataChild)) {
             return optDataChild;
         }
 
@@ -207,4 +207,14 @@ public interface DataNodeContainer {
             parent = (DataNodeContainer) child;
         } while (true);
     }
+
+    private static boolean isDataNode(final Optional<DataSchemaNode> optNode) {
+        return optNode.isPresent() && isDataNode(optNode.orElseThrow());
+    }
+
+    private static boolean isDataNode(final DataSchemaNode node) {
+        return node instanceof ContainerSchemaNode || node instanceof LeafSchemaNode
+                || node instanceof LeafListSchemaNode || node instanceof ListSchemaNode
+                || node instanceof AnydataSchemaNode || node instanceof AnyxmlSchemaNode;
+    }
 }
diff --git a/model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/HelperMethods.java b/model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/HelperMethods.java
deleted file mode 100644 (file)
index 3323cc9..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.model.api;
-
-import java.util.Optional;
-import org.eclipse.jdt.annotation.NonNullByDefault;
-
-/**
- * Package-internal helper methods for use in interface default methods.
- *
- * @author Robert Varga
- */
-@NonNullByDefault
-final class HelperMethods {
-    private HelperMethods() {
-
-    }
-
-    static boolean isDataNode(final Optional<DataSchemaNode> optNode) {
-        return optNode.isPresent() && isDataNode(optNode.get());
-    }
-
-    private static boolean isDataNode(final DataSchemaNode node) {
-        return node instanceof ContainerSchemaNode || node instanceof LeafSchemaNode
-                || node instanceof LeafListSchemaNode || node instanceof ListSchemaNode
-                || node instanceof AnydataSchemaNode || node instanceof AnyxmlSchemaNode;
-    }
-}