Package jsonvalues
Class JsStr
- java.lang.Object
-
- jsonvalues.JsPrimitive
-
- jsonvalues.JsStr
-
- All Implemented Interfaces:
Comparable<JsStr>
,JsValue
public final class JsStr extends JsPrimitive implements Comparable<JsStr>
Represents an immutable json string.
-
-
Field Summary
Fields Modifier and Type Field Description static fun.optic.Prism<String,byte[]>
base64Prism
static fun.optic.Prism<String,Instant>
instantPrism
static fun.optic.Prism<JsValue,String>
prism
prism between the sum type JsValue and JsStrstatic int
TYPE_ID
String
value
The string value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(JsStr o)
Compares twoJsStr
objects lexicographically.boolean
equals(Object that)
Indicates whether some other object is "equal to" this json string.int
hashCode()
Returns the hashcode of this json string.int
id()
boolean
isBinary()
Returns true if this JsValue is a JsBinary or a JsString which value is an array ofboolean
isInstant()
Returns true if this JsValue is a JsInstant or a JsString which value is a date formatted in ISO-8601boolean
isStr()
Returns true if this JsValue is a JsStrJsStr
map(UnaryOperator<String> fn)
Maps this JsStr into another one.static JsStr
of(String str)
Static factory method to create a JsStr from a string.boolean
test(Predicate<String> predicate)
Tests this JsStr on a predicate.JsPrimitive
toJsPrimitive()
String
toString()
Returns the string representation of this json string which is its value quoted.-
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, isInt, isInt, isIntegral, isJson, isLong, isLong, isNothing, isNotNothing, isNotNull, isNotNumber, isNull, isNumber, isObj, isObj, isSameType, isStr, isTrue, toJsArray, toJsBigDec, toJsBigInt, toJsBinary, toJsBool, toJsDouble, toJsInstant, toJsInt, toJsLong, toJsNumber, toJsObj, toJson, toJsStr
-
-
-
-
Field Detail
-
TYPE_ID
public static final int TYPE_ID
- See Also:
- Constant Field Values
-
prism
public static final fun.optic.Prism<JsValue,String> prism
prism between the sum type JsValue and JsStr
-
base64Prism
public static final fun.optic.Prism<String,byte[]> base64Prism
-
value
public final String value
The string value.
-
-
Method Detail
-
of
public static JsStr of(String str)
Static factory method to create a JsStr from a string.- Parameters:
str
- the string- Returns:
- a new JsStr
-
toJsPrimitive
public JsPrimitive toJsPrimitive()
- Specified by:
toJsPrimitive
in interfaceJsValue
-
isStr
public boolean isStr()
Description copied from interface:JsValue
Returns true if this JsValue is a JsStr
-
compareTo
public int compareTo(JsStr o)
Compares twoJsStr
objects lexicographically.- Specified by:
compareTo
in interfaceComparable<JsStr>
- See Also:
String.compareTo(String)
-
test
public boolean test(Predicate<String> predicate)
Tests this JsStr on a predicate.- Parameters:
predicate
- the predicate- Returns:
- true if this string satisfies the predicate
-
hashCode
public int hashCode()
Returns the hashcode of this json string.
-
equals
public boolean equals(Object that)
Indicates whether some other object is "equal to" this json string.
-
toString
public String toString()
Returns the string representation of this json string which is its value quoted.
-
map
public JsStr map(UnaryOperator<String> fn)
Maps this JsStr into another one.- Parameters:
fn
- the mapping function- Returns:
- a new JsStr
-
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
-
isInstant
public boolean isInstant()
Description copied from interface:JsValue
Returns true if this JsValue is a JsInstant or a JsString which value is a date formatted in ISO-8601
-
-