Modifier and Type | Method and Description |
---|---|
static Defaultable<Boolean> |
bool(boolean defaultValue) |
static Defaultable<Boolean> |
bool(Supplier<Boolean> defaultValueSupplier) |
T |
defaultValue()
Retrieve the default value, if any.
|
Optional<T> |
explicit()
Retrieve a standard
Optional containing the explicit value, if any. |
T |
explicitOrElseGet(Supplier<? extends T> other)
Retrieve the explicit value if present, otherwise return the value supplied by the
Supplier parameter. |
T |
explicitValue()
Retrieve the explicitly set value, if any.
|
static Defaultable<Float> |
floating(float defaultValue) |
static Defaultable<Float> |
floating(Supplier<Float> defaultValueSupplier) |
T |
get()
Retrieve the value, regardless of it's origin.
|
T |
get(Supplier<? extends T> preferred)
Retrieve the explicit value if present, followed in precedence by whatever value, if not-null
supplied by the
preferred parameter, followed by the default if all previous
options were null. |
static Defaultable<Boolean> |
ifAllExplicitlySet(Defaultable<?>... items)
Create a
Boolean configuration that has a default value of true if all arguments have been explicitly set to non-default values. |
static Defaultable<Boolean> |
ifAnyExplicitlySet(Defaultable<?>... items)
Create a
Boolean configuration that has a default value of true if any arguments have been explicitly set to non-default values. |
void |
ifDefault(Consumer<? super T> consumer)
If (and only if) only a default value is present (without an explicit value), invoke the supplied consumer with it.
|
void |
ifExplicit(Consumer<? super T> consumer)
If (and only if) an explicit value is present, invoke the supplied consumer with it
|
void |
ifPresent(Consumer<? super T> consumer)
If a default or explicit value is present, invoke the supplied consumer with it.
|
static Defaultable<Integer> |
integer(int defaultValue) |
static Defaultable<Integer> |
integer(Supplier<Integer> defaultValueSupplier) |
boolean |
isDefault()
Determine if the value that would be provided (even if null) is the default value or not.
|
boolean |
isExplicit()
Determine if the value that would be provided is explicitly set or not.
|
boolean |
isExplicitPresent(Supplier<T> other)
Determine if either an explicit value is set of the supplied
other Supplier parameter returns non-null. |
boolean |
isPresent()
Determine if any value (default or explicit) is present.
|
static Defaultable<Long> |
longInteger(long defaultValue) |
static Defaultable<Long> |
longInteger(Supplier<Long> defaultValueSupplier) |
T |
orElse(T defaultValue)
Retrieve the value (default or explicit) if present, otherwise the provided value parameter.
|
T |
orElseGet(Supplier<? extends T> other)
Retrieve the value (default or explicit) if present, otherwise return the value supplied by the
Supplier parameter. |
void |
set(T explicitValue)
Explicitly set a value.
|
static Defaultable<String> |
string(String defaultValue) |
static Defaultable<String> |
string(Supplier<String> defaultValueSupplier) |
Class<T> |
type() |
static Defaultable<URL> |
url(Supplier<URL> defaultValueSupplier) |
static Defaultable<URL> |
url(URL defaultValue) |
public static Defaultable<String> string(String defaultValue)
public static Defaultable<String> string(Supplier<String> defaultValueSupplier)
public static Defaultable<Integer> integer(int defaultValue)
public static Defaultable<Float> floating(float defaultValue)
public static Defaultable<Integer> integer(Supplier<Integer> defaultValueSupplier)
public static Defaultable<Float> floating(Supplier<Float> defaultValueSupplier)
public static Defaultable<Long> longInteger(long defaultValue)
public static Defaultable<Long> longInteger(Supplier<Long> defaultValueSupplier)
public static Defaultable<Boolean> bool(boolean defaultValue)
public static Defaultable<Boolean> bool(Supplier<Boolean> defaultValueSupplier)
public static Defaultable<URL> url(URL defaultValue)
public static Defaultable<URL> url(Supplier<URL> defaultValueSupplier)
public static Defaultable<Boolean> ifAllExplicitlySet(Defaultable<?>... items)
Boolean
configuration that has a default value of true
if all arguments have been explicitly set to non-default values.items
- The items to test.public static Defaultable<Boolean> ifAnyExplicitlySet(Defaultable<?>... items)
Boolean
configuration that has a default value of true
if any arguments have been explicitly set to non-default values.items
- The items to test.public void set(T explicitValue)
explicitValue
- The value to set.public T defaultValue() throws NoSuchElementException
NoSuchElementException
- if no default value is available.public T explicitValue() throws NoSuchElementException
NoSuchElementException
- if no explicit value is available.public T get() throws NoSuchElementException
get
in interface Supplier<T>
NoSuchElementException
- If no value (default nor explicit) is present.public Optional<T> explicit()
Optional
containing the explicit value, if any.
If no explicit value is set, an empty Optional
will be returned.
Optional
wrapper around the explicitly set value, if any.public void ifPresent(Consumer<? super T> consumer)
consumer
- The consumer.public void ifExplicit(Consumer<? super T> consumer)
consumer
- The consumer.public void ifDefault(Consumer<? super T> consumer)
consumer
- The consumer.public T orElse(T defaultValue)
defaultValue
- The value to return only if no value is present.defaultValue
parameter.public T orElseGet(Supplier<? extends T> other)
Supplier
parameter.other
- The value supplier to use to supply a value only if no value is present.other
Supplier
parameter.public T explicitOrElseGet(Supplier<? extends T> other)
Supplier
parameter.other
- The value supplier to use to supply a value only if no explicit value is present.other
Supplier
parameter.public T get(Supplier<? extends T> preferred)
preferred
parameter, followed by the default if all previous
options were null.preferred
- The intermediate value supplier.public boolean isPresent()
true
is a value is present, otherwise false
.public boolean isExplicitPresent(Supplier<T> other)
other
Supplier
parameter returns non-null.other
- The alternative value supplier.true
if either an explicit value is set or the supplier provides a non-null value.public boolean isDefault()
true
only if no explicit value is set.public boolean isExplicit()
true
only if an explicit value is set.Copyright © 2019 JBoss by Red Hat. All rights reserved.