Package jsonvalues

Class JsBigDec

All Implemented Interfaces:
Comparable<JsBigDec>, JsValue

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

    • prism

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

      public final BigDecimal value
      The big decimal value
  • Method Details

    • of

      public static JsBigDec of(BigDecimal n)
      Static factory method to create a JsBigDec from a BigDecimal object.
      Parameters:
      n - the big decimal
      Returns:
      a new JsBigDec
    • isBigDec

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

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

      public int hashCode()
      Returns the hashcode of this JSON big decimal
      Overrides:
      hashCode in class Object
      Returns:
      the hashcode of this JsBigDec
    • equals

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

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      a string representation of the big-decimal value
      See Also:
    • map

      public JsBigDec map(UnaryOperator<BigDecimal> fn)
      Maps this JsBigDec into another one
      Parameters:
      fn - the mapping function
      Returns:
      a new JsBigDec
    • test

      public boolean test(Predicate<BigDecimal> predicate)
      Tests the value of this JSON big-decimal on a predicate
      Parameters:
      predicate - the predicate
      Returns:
      true if this big decimal satisfies the predicate