Class Option<T>
java.lang.Object
org.magicwerk.brownies.collections.helper.Option<T>
- Type Parameters:
T
- element type
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
EMPTY
-
hasValue
private boolean hasValue -
value
-
-
Constructor Details
-
Option
private Option()Prevent construction (use EMPTY) -
Option
Construct option with specified value.- Parameters:
value
- value
-
-
Method Details
-
empty
- Returns:
- unmodifiable empty instance
-
of
-
hasValue
public boolean hasValue()Returns true if a value is stored, false otherwise -
getValueOrNull
Returns stored value of null if no value is stored. It is therefore not possible to distinguish between a null value stored or no value stored. -
getValue
Returns stored value. If no value is stored, an exception is thrown.- Returns:
- stored value
- Throws:
IllegalArgumentException
- if no value is stored
-
equals
-
hashCode
public int hashCode() -
toString
-