Package io.micronaut.core.value
Interface OptionalValues<V>
-
- Type Parameters:
V
- The generic value
- All Superinterfaces:
java.lang.Iterable<java.lang.CharSequence>
- All Known Subinterfaces:
OptionalMultiValues<V>
- All Known Implementing Classes:
OptionalValuesMap
public interface OptionalValues<V> extends java.lang.Iterable<java.lang.CharSequence>
A simple type safe abstraction over a map of optional values.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static OptionalValues
EMPTY_VALUES
Constant for empty values.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static <T> OptionalValues<T>
empty()
An emptyOptionalValues
.default void
forEach(java.util.function.BiConsumer<java.lang.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.java.util.Optional<V>
get(java.lang.CharSequence name)
Retrieve a value if it is present.default boolean
isEmpty()
static <T> OptionalValues<T>
of(java.lang.Class<T> type, java.util.Map<java.lang.CharSequence,?> values)
Creates a newOptionalValues
for the given type and values.java.util.Collection<V>
values()
-
-
-
Field Detail
-
EMPTY_VALUES
static final OptionalValues EMPTY_VALUES
Constant for empty values.
-
-
Method Detail
-
get
java.util.Optional<V> get(java.lang.CharSequence name)
Retrieve a value if it is present.- Parameters:
name
- The name of the value- Returns:
- An
Optional
of the value
-
values
java.util.Collection<V> values()
- Returns:
- The values
-
isEmpty
default boolean isEmpty()
- Returns:
- Whether the
OptionalValues
is empty
-
forEach
default void forEach(java.util.function.BiConsumer<java.lang.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. 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:
java.lang.NullPointerException
- if the specified action is null removed during iteration
-
empty
static <T> OptionalValues<T> empty()
An emptyOptionalValues
.- Type Parameters:
T
- The generic type- Returns:
- The empty values
-
of
static <T> OptionalValues<T> of(java.lang.Class<T> type, @Nullable java.util.Map<java.lang.CharSequence,?> values)
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
-
-