Eliminate DefinitionGenerator#putIfNonNull 93/106893/4
authorMatej Sramcik <matej.sramcik@pantheon.tech>
Wed, 12 Jul 2023 13:02:03 +0000 (15:02 +0200)
committerIvan Hrasko <ivan.hrasko@pantheon.tech>
Tue, 18 Jul 2023 07:54:12 +0000 (07:54 +0000)
Method putIfNonNull(ObjectNode, String, String) is used only once,
so is inlined.

JIRA: NETCONF-1080
Change-Id: I1a9fe96ca4b37bbfe1fc46ee9d697d316591c31c
Signed-off-by: Matej Sramcik <matej.sramcik@pantheon.tech>
restconf/restconf-openapi/src/main/java/org/opendaylight/restconf/openapi/impl/DefinitionGenerator.java

index bd1f8437d0f5be2043438c40a53010ee48c95d9b..65d047b9083053dff19763d4ecaa6a67c3e80f15 100644 (file)
@@ -648,7 +648,9 @@ public class DefinitionGenerator {
             jsonType = STRING_TYPE;
         }
         if (!(leafTypeDef instanceof IdentityrefTypeDefinition)) {
-            putIfNonNull(property, TYPE_KEY, jsonType);
+            if (TYPE_KEY != null && jsonType != null) {
+                property.put(TYPE_KEY, jsonType);
+            }
             if (leafTypeDef.getDefaultValue().isPresent()) {
                 final Object defaultValue = leafTypeDef.getDefaultValue().orElseThrow();
                 if (defaultValue instanceof String stringDefaultValue) {
@@ -909,12 +911,6 @@ public class DefinitionGenerator {
         }
     }
 
-    private static void putIfNonNull(final ObjectNode property, final String key, final String value) {
-        if (key != null && value != null) {
-            property.put(key, value);
-        }
-    }
-
     private static void setExampleValue(final ObjectNode property, final String value) {
         property.put(EXAMPLE_KEY, value);
     }