Package jsonvalues

Class JsInt

All Implemented Interfaces:
Comparable<JsInt>, JsValue

public final class JsInt extends JsNumber implements Comparable<JsInt>
Represents an immutable JSON number of type integer.
  • Field Details

    • prism

      public static final fun.optic.Prism<JsValue,Integer> prism
      prism between the sum type JsValue and JsInt
    • value

      public final int value
      The integer value.
  • Method Details

    • 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
    • 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 Comparable<JsInt>
      See Also:
    • hashCode

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

      public boolean equals(Object that)
      Indicates whether some other object is "equal to" this JSON integer. Numbers of different types are equals if they have the same value.
      Overrides:
      equals in class 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 String toString()
      Overrides:
      toString in class Object
      Returns:
      a string representation of the integer value.
      See Also:
    • map

      public JsInt map(IntUnaryOperator fn)
      Maps this JSON integer into another one.
      Parameters:
      fn - the mapping function
      Returns:
      a new JsInt
    • test

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