Package jsonvalues

Class JsDouble

All Implemented Interfaces:
Comparable<JsDouble>, JsValue

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

    • prism

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

      public final double value
      The double value.
  • Method Details

    • of

      public static JsDouble of(double n)
      Static factory method to create a JsDouble from a double primitive type.
      Parameters:
      n - the double primitive type
      Returns:
      a new JsDouble
    • isDouble

      public boolean isDouble()
      Description copied from interface: JsValue
      Returns true if this JsValue is a JsDouble.
      Specified by:
      isDouble in interface JsValue
      Returns:
      True if this JsValue is a JsDouble.
    • compareTo

      public int compareTo(JsDouble o)
      Compares two JsDouble objects numerically.
      Specified by:
      compareTo in interface Comparable<JsDouble>
      See Also:
    • hashCode

      public int hashCode()
      Returns the hashcode of this json double.
      Overrides:
      hashCode in class Object
      Returns:
      the hashcode of this JsDouble
    • equals

      public boolean equals(Object that)
      Indicates whether some other object is "equal to" this json double. 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 JsDouble
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      a string representation of this object.
      See Also:
    • map

      public JsDouble map(DoubleUnaryOperator fn)
      Maps this json double into another one.
      Parameters:
      fn - the mapping function
      Returns:
      a new JsDouble
    • test

      public boolean test(DoublePredicate predicate)
      Tests the value of this json double on a predicate.
      Parameters:
      predicate - the predicate
      Returns:
      true if this double satisfies the predicate