Package org.spongepowered.api.util
Enum Tristate
- java.lang.Object
-
- java.lang.Enum<Tristate>
-
- org.spongepowered.api.util.Tristate
-
- All Implemented Interfaces:
Serializable,Comparable<Tristate>
public enum Tristate extends Enum<Tristate>
Represents a simple tristate.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Tristateand(Tristate other)ANDs this tristate with another tristate.booleanasBoolean()Returns the boolean representation of this tristate.@Nullable BooleanasNullableBoolean()Returns the nullable boolean representation of this tristate, whereUNDEFINEDequates to null.static TristatefromBoolean(boolean val)Returns the appropriate tristate for a given boolean value.static TristatefromNullableBoolean(@Nullable Boolean val)Returns the appropriate tristate for a given nullable boolean value, where null equates toUNDEFINED.abstract Tristatenot()Negates this tristate.abstract Tristateor(Tristate other)ORs this tristate with another tristate.static TristatevalueOf(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.
-
-
-
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 nameNullPointerException- 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 Boolean val)
Returns the appropriate tristate for a given nullable boolean value, where null equates toUNDEFINED.- 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 Boolean asNullableBoolean()
Returns the nullable boolean representation of this tristate, whereUNDEFINEDequates 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 anOptional.- Returns:
- The nullable boolean tristate representation
-
-