Enum TriState

    • Enum Constant Detail

      • NOT_SET

        public static final TriState NOT_SET
        State describing the absence of a value.
        Since:
        4.8.0
      • FALSE

        public static final TriState FALSE
        State describing a false value.
        Since:
        4.8.0
      • TRUE

        public static final TriState TRUE
        State describing a true value.
        Since:
        4.8.0
    • 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​(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:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • toBoolean

        @Nullable
        public @Nullable Boolean toBoolean()
        Converts this tri-state back into a Boolean.
        Returns:
        the boolean representing this tri-state. NOT_SET will be represented by null.
        Since:
        4.10.0
      • toBooleanOrElse

        public boolean toBooleanOrElse​(boolean other)
        Converts this tri-state back into a boolean.

        As the NOT_SET state cannot be represented by the boolean type, this method maps the NOT_SET state to other passed boolean value. This method may hence also be viewed as an equivalent to Optional.orElse(Object).

        Parameters:
        other - the boolean value that should be returned if this tri-state is NOT_SET.
        Returns:
        the boolean representing the tri-state or the boolean passed if this state is NOT_SET.
        Since:
        4.10.0
      • toBooleanOrElseGet

        public boolean toBooleanOrElseGet​(@NotNull
                                          @NotNull BooleanSupplier supplier)
        Converts this tri-state back into a boolean.

        As the NOT_SET state cannot be represented by the boolean type, this method maps the NOT_SET state to the suppliers result. This method may hence also be viewed as an equivalent to Optional.orElseGet(java.util.function.Supplier).

        Parameters:
        supplier - the supplier that will be executed to produce the value that should be returned if this tri-state is NOT_SET.
        Returns:
        the boolean representing the tri-state or the result of the passed supplier if this state is NOT_SET.
        Since:
        4.10.0
      • byBoolean

        @NotNull
        public static @NotNull TriState byBoolean​(boolean value)
        Gets a state from a boolean.
        Parameters:
        value - the boolean
        Returns:
        a tri-state
        Since:
        4.8.0
      • byBoolean

        @NotNull
        public static @NotNull TriState byBoolean​(@Nullable
                                                  @Nullable Boolean value)
        Gets a state from a Boolean.
        Parameters:
        value - the boolean
        Returns:
        a tri-state
        Since:
        4.8.0