Package io.micronaut.core.value
Interface OptionalValues<V>
- Type Parameters:
V
- The generic value
- All Superinterfaces:
Iterable<CharSequence>
- All Known Subinterfaces:
OptionalMultiValues<V>
- All Known Implementing Classes:
OptionalValuesMap
A simple type safe abstraction over a map of optional values.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> OptionalValues<T>
empty()
An emptyOptionalValues
.default void
forEach
(BiConsumer<CharSequence, ? super V> action) Performs the given action for each entry in thisOptionalValues
until all entries have been processed or the action throws an exception.get
(CharSequence name) Retrieve a value if it is present.default boolean
isEmpty()
static <T> OptionalValues<T>
of
(Class<T> type, @Nullable Map<CharSequence, ?> values) Creates a newOptionalValues
for the given type and values.values()
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Field Details
-
EMPTY_VALUES
Constant for empty values.
-
-
Method Details
-
get
Retrieve a value if it is present.- Parameters:
name
- The name of the value- Returns:
- An
Optional
of the value
-
values
Collection<V> values()- Returns:
- The values
-
isEmpty
default boolean isEmpty()- Returns:
- Whether the
OptionalValues
is empty
-
forEach
Performs the given action for each entry in thisOptionalValues
until all entries have been processed or the action throws an exception. Unless otherwise specified by the implementing class, actions are performed in the order of entry set iteration (if an iteration order is specified.) Exceptions thrown by the action are relayed to the caller.- Parameters:
action
- The action to be performed for each entry- Throws:
NullPointerException
- if the specified action is null removed during iteration
-
empty
An emptyOptionalValues
.- Type Parameters:
T
- The generic type- Returns:
- The empty values
-
of
Creates a newOptionalValues
for the given type and values.- Type Parameters:
T
- The target generic type- Parameters:
type
- The target typevalues
- A map of values- Returns:
- The values
-