Interface OptionalValues<V>

Type Parameters:
V - The generic value
All Superinterfaces:
Iterable<CharSequence>
All Known Subinterfaces:
OptionalMultiValues<V>
All Known Implementing Classes:
OptionalValuesMap

public interface OptionalValues<V> extends Iterable<CharSequence>
A simple type safe abstraction over a map of optional values.
Since:
1.0
Author:
Graeme Rocher
  • Field Details

    • EMPTY_VALUES

      static final OptionalValues EMPTY_VALUES
      Constant for empty values.
  • Method Details

    • get

      Optional<V> get(CharSequence name)
      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

      default void forEach(BiConsumer<CharSequence,? super V> action)
      Performs the given action for each entry in this OptionalValues 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

      static <T> OptionalValues<T> empty()
      An empty OptionalValues.
      Type Parameters:
      T - The generic type
      Returns:
      The empty values
    • of

      static <T> OptionalValues<T> of(Class<T> type, @Nullable @Nullable Map<CharSequence,?> values)
      Creates a new OptionalValues for the given type and values.
      Type Parameters:
      T - The target generic type
      Parameters:
      type - The target type
      values - A map of values
      Returns:
      The values