Package jsonvalues

Class JsBinary

  • All Implemented Interfaces:
    JsValue

    public final class JsBinary
    extends JsPrimitive
    Represents an array of bytes. This type is not part of the Json specification. It is serialized into a string using Base64 encoding scheme. A JsBinary and a JsStr are equals if the string is the array of bytes encoded in base64. byte[] bytes = "foo".getBytes(); String base64 = Base64.getEncoder().encodeToString(bytes); JsBinary.of(bytes).equals(JsStr.of(base64)); // true
    • Field Detail

      • prism

        public static final fun.optic.Prism<JsValue,​byte[]> prism
        prism between the sum type JsValue and JsBinary
      • value

        public final byte[] value
    • Method Detail

      • of

        public static JsBinary of​(byte[] bytes)
        Creates a JsBinary from an array of bytes
        Parameters:
        bytes - the array of bytes
        Returns:
        an immutable JsBinary
      • of

        public static JsBinary of​(String base64)
        Creates a JsBinary from an array of bytes encoded as a string in base64
        Parameters:
        base64 - the string
        Returns:
        an immutable JsBinary
        Throws:
        IllegalArgumentException - if base64 is not in valid Base64 scheme
      • id

        public int id()
      • isBinary

        public boolean isBinary()
        Description copied from interface: JsValue
        Returns true if this JsValue is a JsBinary or a JsString which value is an array of
        Returns:
        true if this JsValue is a JsBinary or a JsString which value is an array of bytes encoded in base64
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object