java.lang.Object
jsonvalues.JsPrimitive
jsonvalues.JsBinary
- All Implemented Interfaces:
JsValue
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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionboolean
int
hashCode()
boolean
isBinary()
Returns true if this JsValue is a JsBinary or a JsString which value is an array ofstatic JsBinary
of
(byte[] bytes) Creates a JsBinary from an array of bytesstatic JsBinary
Creates a JsBinary from an array of bytes encoded as a string in base64toString()
Methods inherited from class jsonvalues.JsPrimitive
isJson, isPrimitive
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface jsonvalues.JsValue
ifNothing, ifNull, isArray, isArray, isBigDec, isBigDec, isBigInt, isBigInt, isBool, isDecimal, isDouble, isDouble, isFalse, isInstant, isInstant, isInt, isInt, isIntegral, isJson, isLong, isLong, isNothing, isNotNothing, isNotNull, isNotNumber, isNull, isNumber, isObj, isObj, isSameType, isStr, isStr, isTrue, toJsArray, toJsBigDec, toJsBigInt, toJsBinary, toJsBool, toJsDouble, toJsInstant, toJsInt, toJsLong, toJsNumber, toJsObj, toJson, toJsStr
-
Field Details
-
prism
prism between the sum type JsValue and JsBinary -
value
public final byte[] value
-
-
Method Details
-
of
Creates a JsBinary from an array of bytes- Parameters:
bytes
- the array of bytes- Returns:
- an immutable JsBinary
-
of
Creates a JsBinary from an array of bytes encoded as a string in base64- Parameters:
base64
- the string- Returns:
- an immutable JsBinary
- Throws:
IllegalArgumentException
- ifbase64
is not in valid Base64 scheme
-
toJsPrimitive
-
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
-
toString
-
equals
-
hashCode
public int hashCode()
-