public class Trilean
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
static Trilean |
FALSE
The static value for False
|
static Trilean |
TRUE
The static value for True
|
static Trilean |
UNKNOWN
The static value for Unknown (neither true or false)
|
Constructor and Description |
---|
Trilean(boolean isTrue,
boolean isFalse)
Construct a new Trilean value.
|
Trilean(Trilean other)
The copy constructor.
|
Modifier and Type | Method and Description |
---|---|
Trilean |
and(Trilean other)
Returns the logical and of this and the other value.
|
boolean |
equals(java.lang.Object other)
Returns whether this Trilean is equal either to the given Trilean, or the given Boolean.
|
static Trilean |
from(boolean bool)
Create the Trilean value for the given Boolean
|
static Trilean |
fromString(java.lang.String value) |
int |
hashCode() |
boolean |
isFalse()
Returns true if this Trilean is false, and false if it is true or unknown.
|
boolean |
isKnown()
Returns true if this Trilean is either true or false, and false if it is unknown.
|
boolean |
isTrue()
Returns true if this Trilean is true, and false if it is false or unknown.
|
boolean |
isUnknown()
Returns true if this Trilean is neither true or false, and false if it is either true or false.
|
Trilean |
not()
Returns the logical not of this value.
|
Trilean |
or(Trilean other)
Returns the logical or of this and the other value.
|
boolean |
toBoolean(boolean valueForUnknown)
Convert this Trilean to a boolean, with a specified default value if the truth value is unknown.
|
java.lang.Boolean |
toBooleanOrNull()
Convert this Trilean to a Boolean, or null if the value is not known.
|
java.lang.String |
toString()
Returns a String representation of this Trilean: either "true", "false", or "unknown".
|
public static Trilean TRUE
public static Trilean FALSE
public static Trilean UNKNOWN
public Trilean(boolean isTrue, boolean isFalse)
isTrue
- Set to true if the value is true. Set to false if the value is false or unknown.isFalse
- Set to true if the value is false. Set to false if the value is true or unknown.public Trilean(Trilean other)
other
- The value to copy from.public boolean isTrue()
public boolean isFalse()
public boolean isKnown()
public boolean isUnknown()
public boolean toBoolean(boolean valueForUnknown)
valueForUnknown
- The default value to use if the value of this Trilean is unknown.public java.lang.Boolean toBooleanOrNull()
public Trilean and(Trilean other)
other
- The value to and this value with.public Trilean or(Trilean other)
other
- The value to or this value with.public Trilean not()
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
Implementation note: this hash code should be consistent with Boolean.hashCode()
.
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public static Trilean from(boolean bool)
public static Trilean fromString(java.lang.String value)