import static com.google.common.base.Verify.verify;
import static java.util.Objects.requireNonNull;
+import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.base.VerifyException;
import java.util.Arrays;
import java.util.List;
return value;
}
+ /**
+ * Append a named value to a ToStringHelper. If the value is null, this method does nothing.
+ *
+ * @param helper Helper to append to
+ * @param name Name of the value
+ * @param value Value to append
+ * @throws NullPointerException if the name or helper is null
+ */
+ public static void appendValue(final @NonNull ToStringHelper helper, final @NonNull String name,
+ final @Nullable Object value) {
+ if (value != null) {
+ helper.add(name, value);
+ }
+ }
+
+ /**
+ * Append a named value to a ToStringHelper. If the value is null, this method does nothing.
+ *
+ * @param helper Helper to append to
+ * @param name Name of the value
+ * @param value Value to append
+ * @throws NullPointerException if the name or helper is null
+ */
+ public static void appendValue(final ToStringHelper helper, final String name, final byte[] value) {
+ if (value != null) {
+ helper.add(name, Arrays.toString(value));
+ }
+ }
+
/**
* Compile a list of pattern regular expressions and return them as an array. The list must hold at least two
* expressions.