Enum Tristate

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<Tristate>

    public enum Tristate
    extends java.lang.Enum<Tristate>
    Represents a simple tristate.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      FALSE  
      TRUE  
      UNDEFINED  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract Tristate and​(Tristate other)
      ANDs this tristate with another tristate.
      boolean asBoolean()
      Returns the boolean representation of this tristate.
      @Nullable java.lang.Boolean asNullableBoolean()
      Returns the nullable boolean representation of this tristate, where UNDEFINED equates to null.
      static Tristate fromBoolean​(boolean val)
      Returns the appropriate tristate for a given boolean value.
      static Tristate fromNullableBoolean​(@Nullable java.lang.Boolean val)
      Returns the appropriate tristate for a given nullable boolean value, where null equates to UNDEFINED.
      abstract Tristate not()
      Negates this tristate.
      abstract Tristate or​(Tristate other)
      ORs this tristate with another tristate.
      static Tristate valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static Tristate[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • TRUE

        public static final Tristate TRUE
      • FALSE

        public static final Tristate FALSE
      • UNDEFINED

        public static final Tristate UNDEFINED
    • Method Detail

      • values

        public static Tristate[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Tristate c : Tristate.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Tristate valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • fromBoolean

        public static Tristate fromBoolean​(boolean val)
        Returns the appropriate tristate for a given boolean value.
        Parameters:
        val - The boolean value
        Returns:
        The appropriate tristate
      • fromNullableBoolean

        public static Tristate fromNullableBoolean​(@Nullable java.lang.Boolean val)
        Returns the appropriate tristate for a given nullable boolean value, where null equates to UNDEFINED.
        Parameters:
        val - The nullable boolean value
        Returns:
        The appropriate tristate
      • and

        public abstract Tristate and​(Tristate other)
        ANDs this tristate with another tristate.
        Parameters:
        other - The tristate to AND with
        Returns:
        The result
      • or

        public abstract Tristate or​(Tristate other)
        ORs this tristate with another tristate.
        Parameters:
        other - The tristate to OR with
        Returns:
        The result
      • not

        public abstract Tristate not()
        Negates this tristate.
        Returns:
        The result
      • asBoolean

        public boolean asBoolean()
        Returns the boolean representation of this tristate.
        Returns:
        The boolean tristate representation
      • asNullableBoolean

        public @Nullable java.lang.Boolean asNullableBoolean()
        Returns the nullable boolean representation of this tristate, where UNDEFINED equates to null.

        Note: To ensure that there is a one-to-one mapping of nullable booleans to and from Tristate, this method will return null rather than use an Optional.

        Returns:
        The nullable boolean tristate representation