Class Booleans


  • @ParametersAreNonnullByDefault
    public final class Booleans
    extends Object
    Static utility methods related to boolean and Boolean.
    • Method Detail

      • toBytes

        @Nonnull
        public static byte[] toBytes​(boolean value)
        Encodes a boolean to a byte array.
        Parameters:
        value - the value to encode
        Returns:
        a byte array
      • toBytes

        @Nonnull
        public static byte[] toBytes​(Boolean value)
        Encodes a Boolean to a byte array.
        Parameters:
        value - the value to encode
        Returns:
        a byte array
        Throws:
        NullPointerException - if the value is null
      • toInt

        @Nonnegative
        public static int toInt​(boolean value)
        Returns the integer value of a boolean value. In other words, returns 1 when value == true, 0 otherwise.
        Parameters:
        value - the boolean value
        Returns:
        an int