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 TypeMethodDescriptionbooleaninthashCode()booleanisBinary()Returns true if this JsValue is a JsBinary or a JsString which value is an array ofstatic JsBinaryof(byte[] bytes) Creates a JsBinary from an array of bytesstatic JsBinaryCreates a JsBinary from an array of bytes encoded as a string in base64toString()Methods inherited from class jsonvalues.JsPrimitive
isJson, isPrimitiveMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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[] valuethe array of bytes
-
-
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- ifbase64is not in valid Base64 scheme
-
toJsPrimitive
-
isBinary
public boolean isBinary()Description copied from interface:JsValueReturns 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()
-