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
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      static <T> OptionalValues<T> empty()
      An empty OptionalValues.
      default void forEach​(java.util.function.BiConsumer<java.lang.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.
      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 new OptionalValues for the given type and values.
      java.util.Collection<V> values()  
      • Methods inherited from interface java.lang.Iterable

        forEach, iterator, spliterator
    • 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 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:
        java.lang.NullPointerException - if the specified action is null removed during iteration
      • of

        static <T> OptionalValues<T> of​(java.lang.Class<T> type,
                                        @Nullable
                                        java.util.Map<java.lang.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