diff options
author | 2016-05-30 12:45:00 +0200 | |
---|---|---|
committer | 2016-06-06 12:52:00 +0000 | |
commit | bf617ea1f6652482c6e9cfd7b99c071db302bfdf (patch) | |
tree | b1c8efd16a39c12e046cffc9b1da7ec0d171a4ea /v3po/vpp-translate-utils/src/main | |
parent | dcbcc649b804347ecb8e9344efa5c6e6745488b7 (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')
-rw-r--r-- | v3po/vpp-translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/v3po/util/TranslateUtils.java | 16 |
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)); + } } |