Package jsonvalues

Class JsDouble

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

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

      • prism

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

        public final double value
        The double value.
    • Method Detail

      • id

        public int id()
        Specified by:
        id in interface JsValue
      • 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 java.lang.Comparable<JsDouble>
        See Also:
        Double.compareTo(Double)
      • hashCode

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

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

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

        public JsDouble map​(java.util.function.DoubleUnaryOperator fn)
        Maps this json double into another one.
        Parameters:
        fn - the mapping function
        Returns:
        a new JsDouble
      • 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
      • test

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