summaryrefslogtreecommitdiffstats
path: root/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-05-30 12:45:00 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-06-06 12:52:00 +0000
commitd2f203522c5384ad411bc9dad38c5f87b0e63abd (patch)
tree9947dd3c45d32fa4270da1bc110150f749eb2d46 /v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util
parenta54aa10434f8a1d08c01c015006cdf0077c8f54c (diff)
Move byteToBoolean to TranslateUtils
Change-Id: I7a8142bc2df7d566bc3edde7ceb42eb6b8815852 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util')
-rw-r--r--v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java b/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java
index f14b2eb6d..b13dbb4fe 100644
--- a/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java
+++ b/v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java
@@ -129,4 +129,20 @@ public final class TranslateUtils {
public static byte booleanToByte(@Nullable final Boolean value) {
return value != null && value ? (byte) 1 : (byte) 0;
}
+
+ /**
+ * Returns Boolean.TRUE if argument is 0, Boolean.FALSE otherwise.
+ * @param value byte value to be converted
+ * @return Boolean value
+ * @throws IllegalArgumentException if argument is neither 0 nor 1
+ */
+ @Nonnull
+ public static Boolean byteToBoolean(final byte value) {
+ if (value == 0) {
+ return Boolean.FALSE;
+ } else if (value == 1) {
+ return Boolean.TRUE;
+ }
+ throw new IllegalArgumentException(String.format("0 or 1 was expected but was %d", value));
+ }
}