Package jsonvalues

Class JsBool

All Implemented Interfaces:
JsValue

public final class JsBool extends JsPrimitive
Represents an immutable JSON boolean. Only two instances are created: FALSE and TRUE
  • Field Details

    • FALSE

      public static final JsBool FALSE
      The singleton false value.
    • TRUE

      public static final JsBool TRUE
      The singleton true value.
    • prism

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

      public final boolean value
      the boolean value.
  • Method Details

    • of

      public static JsBool of(boolean b)
      Static factory method to create a JsBool from a boolean primitive type.
      Parameters:
      b - the boolean value
      Returns:
      either TRUE or FALSE
    • toJsPrimitive

      public JsPrimitive toJsPrimitive()
      Description copied from interface: JsValue
      Returns this JsValue as a JsPrimitive.
      Returns:
      This JsValue as a JsPrimitive.
    • isBool

      public boolean isBool()
      Description copied from interface: JsValue
      Returns true if this JsValue is a JsBool.
      Returns:
      True if this JsValue is a JsBool.
    • isTrue

      public boolean isTrue()
      Description copied from interface: JsValue
      Returns true if this JsValue is a JsBool and its value is true.
      Returns:
      True if this JsValue is a JsBool and its value is true.
    • isFalse

      public boolean isFalse()
      Description copied from interface: JsValue
      Returns true if this JsValue is a JsBool and its value is false.
      Returns:
      True if this JsValue is a JsBool and its value is false.
    • hashCode

      public int hashCode()
      Returns the hashcode of this JSON boolean.
      Overrides:
      hashCode in class Object
      Returns:
      1 if true, 0 if false
    • equals

      public boolean equals(Object that)
      Indicates whether some other object is "equal to" this JSON boolean.
      Overrides:
      equals in class Object
      Parameters:
      that - the reference object with which to compare.
      Returns:
      true if that is a JsBool with the same value as this JsBool
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      "true" or "false"