Package jsonvalues

Class JsBool

  • All Implemented Interfaces:
    JsValue

    public final class JsBool
    extends Object
    implements JsValue
    Represents an immutable json boolean. Only two instances are created: FALSE and TRUE
    • Field Detail

      • FALSE

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

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

        public final boolean value
        the boolean value.
    • Method Detail

      • id

        public int id()
        Specified by:
        id in interface JsValue
      • equals

        public boolean equals​(@Nullable 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
      • hashCode

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

        public JsBool negate()
        Negates this json boolean (implementation of ! operator).
        Returns:
        the inverse value of this
      • 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
      • toString

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

        public boolean isBool()
        Specified by:
        isBool in interface JsValue
        Returns:
        true if this JsElem is a JsBool
      • isTrue

        public boolean isTrue()
        Specified by:
        isTrue in interface JsValue
        Returns:
        true if this JsElem is a JsBool and it's true
      • isFalse

        public boolean isFalse()
        Specified by:
        isFalse in interface JsValue
        Returns:
        true if this JsElem is a JsBool and it's false