Package jsonvalues

Class JsInt

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

    public final class JsInt
    extends JsNumber
    implements java.lang.Comparable<JsInt>
    Represents an immutable json number of type integer.
    • Field Detail

      • prism

        public static final Prism<JsValue,​java.lang.Integer> prism
        prism between the sum type JsValue and JsInt
      • value

        public final int value
        The integer value.
    • Method Detail

      • id

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

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

        public int compareTo​(JsInt o)
        Compares two JsInt objects numerically.
        Specified by:
        compareTo in interface java.lang.Comparable<JsInt>
        See Also:
        Integer.compareTo(Integer)
      • hashCode

        public int hashCode()
        Returns the hashcode of this json integer.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        hashcode of this JsInt
      • equals

        public boolean equals​(java.lang.Object that)
        Indicates whether some other object is "equal to" this json integer. Numbers of different types are equals if the have the same value.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        that - the reference object with which to compare.
        Returns:
        true if that is a JsNumber with the same value as this JsInt.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of the integer value.
        See Also:
        Integer.toString
      • map

        public JsInt map​(java.util.function.IntUnaryOperator fn)
        Maps this json integer into another one.
        Parameters:
        fn - the mapping function
        Returns:
        a new JsInt
      • of

        public static JsInt of​(int n)
        Static factory method to create a JsInt from an integer primitive type.
        Parameters:
        n - the integer primitive type
        Returns:
        a new JsInt
      • test

        public boolean test​(java.util.function.IntPredicate predicate)
        /** Tests the value of this json integer on a predicate.
        Parameters:
        predicate - the predicate
        Returns:
        true if this integer satisfies the predicate