Do not use appendValue to append bits
[mdsal.git] / binding / yang-binding / src / main / java / org / opendaylight / yangtools / yang / binding / CodeHelpers.java
index e12cb35a88b4a4883a9072f7c19842ee99b05c53..2b41164122522e1a05a9491a5b0e30e76bf0ef58 100644 (file)
@@ -93,6 +93,20 @@ public final class CodeHelpers {
         requireNonNull(value, "Supplied value may not be null");
     }
 
+    /**
+     * Append a {@code bits} individual value. If the value is {@code false}, this method does nothing.
+     *
+     * @param helper Helper to append to
+     * @param name Name of the bit
+     * @param value Value to append
+     * @throws NullPointerException if any argument is {@code null}
+     */
+    public static void appendBit(final ToStringHelper helper, final @NonNull String name, final boolean value) {
+        if (value) {
+            helper.addValue(name);
+        }
+    }
+
     /**
      * Append a named value to a ToStringHelper. If the value is null, this method does nothing.
      *