Filter empty augmentations from DataObject.toString()
[mdsal.git] / binding / yang-binding / src / main / java / org / opendaylight / yangtools / yang / binding / CodeHelpers.java
index 8de4954d319ea292de6f87177f04bc64533afedf..9f24fe2c45ac719f88d648e007fcf307ddd6fc8c 100644 (file)
@@ -119,6 +119,23 @@ public final class CodeHelpers {
         }
     }
 
+    /**
+     * Append augmentation map of an Augmentable to a ToStringHelper. If augmentations are null or empt, this method
+     * does nothing.
+     *
+     * @param helper Helper to append to
+     * @param name Name of the augmentation value
+     * @param augmentable Augmentable object to
+     * @throws NullPointerException if any argument is null
+     */
+    public static void appendAugmentations(final ToStringHelper helper, final String name,
+            final Augmentable<?> augmentable) {
+        final var augments = augmentable.augmentations();
+        if (!augments.isEmpty()) {
+            helper.add(name, augments.values());
+        }
+    }
+
     /**
      * Compile a list of pattern regular expressions and return them as an array. The list must hold at least two
      * expressions.