Package jsonvalues

Class JsStr

  • All Implemented Interfaces:
    java.lang.Comparable<JsStr>, JsValue

    public final class JsStr
    extends JsPrimitive
    implements java.lang.Comparable<JsStr>
    Represents an immutable json string.
    • Field Detail

      • prism

        public static final Prism<JsValue,​java.lang.String> prism
        prism between the sum type JsValue and JsStr
      • base64Prism

        public static final Prism<java.lang.String,​byte[]> base64Prism
      • instantPrism

        public static final Prism<java.lang.String,​java.time.Instant> instantPrism
      • value

        public final java.lang.String value
        The string value.
    • Method Detail

      • id

        public int id()
        Specified by:
        id in interface JsValue
      • isStr

        public boolean isStr()
        Description copied from interface: JsValue
        Returns true if this JsValue is a JsStr
        Specified by:
        isStr in interface JsValue
        Returns:
        true if this JsValue is a JsStr
      • compareTo

        public int compareTo​(JsStr o)
        Compares two JsStr objects lexicographically.
        Specified by:
        compareTo in interface java.lang.Comparable<JsStr>
        See Also:
        String.compareTo(String)
      • test

        public boolean test​(java.util.function.Predicate<java.lang.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.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        hashcode of this JsStr
      • equals

        public boolean equals​(java.lang.Object that)
        Indicates whether some other object is "equal to" this json string.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        that - the reference object with which to compare.
        Returns:
        true if that is a JsStr with the same value as this JsStr
      • toString

        public java.lang.String toString()
        Returns the string representation of this json string which is its value quoted.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the value quoted.
      • map

        public JsStr map​(java.util.function.UnaryOperator<java.lang.String> fn)
        Maps this JsStr into another one.
        Parameters:
        fn - the mapping function
        Returns:
        a new JsStr
      • of

        public static JsStr of​(java.lang.String str)
        Static factory method to create a JsStr from a string.
        Parameters:
        str - the string
        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
        Specified by:
        isBinary in interface JsValue
        Returns:
        true if this JsValue is a JsBinary or a JsString which value is an array of bytes encoded in base64
      • 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
        Specified by:
        isInstant in interface JsValue
        Returns:
        true if this JsValue is a JsInstant or a JsString which value is a date formatted in ISO-8601