Remove RestconfConstants.SLASH_SPLITTER 61/107061/3
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 25 Jul 2023 16:12:43 +0000 (18:12 +0200)
committerRobert Varga <nite@hq.sk>
Tue, 25 Jul 2023 20:46:24 +0000 (20:46 +0000)
This is a utility, used independently by two components. Eliminate it by
copying it to their respective users.

Change-Id: I43a7d103396e35f22d1a0873317856b7191203b2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/SubscribeToStreamUtil.java
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/RestconfConstants.java
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/utils/parser/ParserIdentifier.java

index 00174f72552aa27dac888117a6fcf9d12ca042c1..59469b019d78d39353dd79e0882893ed37026a59 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.restconf.nb.rfc8040.rests.services.impl;
 
 import static com.google.common.base.Strings.isNullOrEmpty;
 
+import com.google.common.base.Splitter;
 import java.net.URI;
 import java.util.HashMap;
 import java.util.Map;
@@ -81,8 +82,8 @@ abstract class SubscribeToStreamUtil {
         }
     }
 
-
     private static final Logger LOG = LoggerFactory.getLogger(SubscribeToStreamUtil.class);
+    private static final Splitter SLASH_SPLITTER = Splitter.on('/');
 
     SubscribeToStreamUtil() {
         // Hidden on purpose
@@ -224,8 +225,8 @@ abstract class SubscribeToStreamUtil {
      * @return Map od URI parameters and values.
      */
     private static Map<String, String> mapValuesFromUri(final String identifier) {
-        final HashMap<String, String> result = new HashMap<>();
-        for (final String token : RestconfConstants.SLASH_SPLITTER.split(identifier)) {
+        final var result = new HashMap<String, String>();
+        for (final String token : SLASH_SPLITTER.split(identifier)) {
             final String[] paramToken = token.split("=");
             if (paramToken.length == 2) {
                 result.put(paramToken[0], paramToken[1]);
index 2979e028a9298d7bfd6446e2ba552789d432afbf..3c7e4db1431beb2da687d9c315c43cd7de221834 100644 (file)
@@ -7,13 +7,10 @@
  */
 package org.opendaylight.restconf.nb.rfc8040.utils;
 
-import com.google.common.base.Splitter;
-
 /**
  * Util class for Restconf constants.
  */
 public final class RestconfConstants {
-    public static final Splitter SLASH_SPLITTER = Splitter.on('/');
     public static final String BASE_URI_PATTERN = "rests";
     public static final String NOTIF = "notif";
 
index 1f30f97fbc46de46cd3f6552d5a6e0f231d585c7..d44dee61b5777cad94325fac0d402aa7df2a26a9 100644 (file)
@@ -29,7 +29,6 @@ import org.opendaylight.restconf.common.ErrorTags;
 import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.nb.rfc8040.rests.services.api.SchemaExportContext;
-import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
 import org.opendaylight.yangtools.yang.common.ErrorTag;
 import org.opendaylight.yangtools.yang.common.ErrorType;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -54,6 +53,7 @@ public final class ParserIdentifier {
     //        EffectiveModelContext and allowing it only where yang-ext:mount is actually used in models.
     private static final String MOUNT = "yang-ext:mount";
     private static final Splitter MP_SPLITTER = Splitter.on("/" + MOUNT);
+    private static final Splitter SLASH_SPLITTER = Splitter.on('/');
 
     private ParserIdentifier() {
         // Hidden on purpose
@@ -150,7 +150,7 @@ public final class ParserIdentifier {
             moduleNameAndRevision = identifier;
         }
 
-        final List<String> pathArgs = RestconfConstants.SLASH_SPLITTER.splitToList(moduleNameAndRevision);
+        final List<String> pathArgs = SLASH_SPLITTER.splitToList(moduleNameAndRevision);
         if (pathArgs.size() != 2) {
             LOG.debug("URI has bad format '{}'. It should be 'moduleName/yyyy-MM-dd'", identifier);
             throw new RestconfDocumentedException(
@@ -186,7 +186,7 @@ public final class ParserIdentifier {
     public static SchemaExportContext toSchemaExportContextFromIdentifier(final EffectiveModelContext schemaContext,
             final String identifier, final DOMMountPointService domMountPointService,
             final DOMYangTextSourceProvider sourceProvider) {
-        final Iterable<String> pathComponents = RestconfConstants.SLASH_SPLITTER.split(identifier);
+        final Iterable<String> pathComponents = SLASH_SPLITTER.split(identifier);
         final Iterator<String> componentIter = pathComponents.iterator();
         if (!Iterables.contains(pathComponents, MOUNT)) {
             final String moduleName = validateAndGetModulName(componentIter);