Clean up parseNotificationStreamName() 75/107075/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 26 Jul 2023 09:34:03 +0000 (11:34 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 26 Jul 2023 09:37:43 +0000 (11:37 +0200)
Do not convert the enumeration to a String for comparison purposes.

Change-Id: I6c9eb92835cc3004fa2e57f16583aae1c8c8fb09
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtil.java

index de6717c08f380b092f6bbd1d985373cdb2d89130..3c96b213ac22af8e42b08f5d4e1602bd141e467b 100644 (file)
@@ -266,7 +266,7 @@ final class CreateStreamUtil {
     static NotificationListenerAdapter createYangNotifiStream(final NotificationDefinition notificationDefinition,
             final EffectiveModelContext refSchemaCtx, final NotificationOutputType outputType) {
         final var streamName = parseNotificationStreamName(requireNonNull(notificationDefinition),
-                requireNonNull(refSchemaCtx), requireNonNull(outputType.getName()));
+                requireNonNull(refSchemaCtx), requireNonNull(outputType));
         final var listenersBroker = ListenersBroker.getInstance();
 
         final var existing = listenersBroker.notificationListenerFor(streamName);
@@ -276,7 +276,7 @@ final class CreateStreamUtil {
     }
 
     private static String parseNotificationStreamName(final NotificationDefinition notificationDefinition,
-            final EffectiveModelContext refSchemaCtx, final String outputType) {
+            final EffectiveModelContext refSchemaCtx, final NotificationOutputType outputType) {
         final QName notificationDefinitionQName = notificationDefinition.getQName();
         final Module module = refSchemaCtx.findModule(
                 notificationDefinitionQName.getModule().getNamespace(),
@@ -290,8 +290,8 @@ final class CreateStreamUtil {
                 .append(module.getName())
                 .append(':')
                 .append(notificationDefinitionQName.getLocalName());
-        if (outputType.equals(NotificationOutputType.JSON.getName())) {
-            streamNameBuilder.append('/').append(NotificationOutputType.JSON.getName());
+        if (outputType != NotificationOutputType.XML) {
+            streamNameBuilder.append('/').append(outputType.getName());
         }
         return streamNameBuilder.toString();
     }