- java.lang.Object
-
- java.lang.Enum<OptionalBoolean>
-
- com.speedment.common.function.OptionalBoolean
-
- All Implemented Interfaces:
Serializable,Comparable<OptionalBoolean>
public enum OptionalBoolean extends Enum<OptionalBoolean>
AnOptionalspecialized for primitive boolean values.- Since:
- 1.0.0
- Author:
- Emil Forslund
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static OptionalBooleanempty()OptionalBooleanfilter(BooleanPredicate predicate)If a value is present, and the value matches the given predicate, return aBooleanOptionaldescribing the value, otherwise return an emptyBooleanOptional.booleangetAsBoolean()abstract voidifPresent(BooleanConsumer consumer)abstract booleanisPresent()static OptionalBooleanof(boolean bool)static OptionalBooleanofNullable(Boolean bool)booleanorElse(boolean ifEmpty)abstract <T extends Throwable>
booleanorElseThrow(Supplier<T> thrower)static OptionalBooleanvalueOf(String name)Returns the enum constant of this type with the specified name.static OptionalBoolean[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
FALSE
public static final OptionalBoolean FALSE
-
TRUE
public static final OptionalBoolean TRUE
-
EMPTY
public static final OptionalBoolean EMPTY
-
-
Method Detail
-
values
public static OptionalBoolean[] 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 (OptionalBoolean c : OptionalBoolean.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static OptionalBoolean 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
-
empty
public static OptionalBoolean empty()
-
of
public static OptionalBoolean of(boolean bool)
-
ofNullable
public static OptionalBoolean ofNullable(Boolean bool)
-
filter
public OptionalBoolean filter(BooleanPredicate predicate)
If a value is present, and the value matches the given predicate, return aBooleanOptionaldescribing the value, otherwise return an emptyBooleanOptional.- Parameters:
predicate- a predicate to apply to the value, if present- Returns:
- a
BooleanOptionaldescribing the value of thisBooleanOptionalif a value is present and the value matches the given predicate, otherwise an emptyBooleanOptional - Throws:
NullPointerException- if the predicate is null
-
getAsBoolean
public boolean getAsBoolean()
-
orElse
public boolean orElse(boolean ifEmpty)
-
orElseThrow
public abstract <T extends Throwable> boolean orElseThrow(Supplier<T> thrower) throws T extends Throwable
- Throws:
T extends Throwable
-
isPresent
public abstract boolean isPresent()
-
ifPresent
public abstract void ifPresent(BooleanConsumer consumer)
-
-