Class Maybe.MaybeConsumer<T>

  • Type Parameters:
    T - The type contained within the Maybe, maybe.
    All Implemented Interfaces:
    Consumer<Maybe<T>>
    Enclosing class:
    Maybe<T>

    public static final class Maybe.MaybeConsumer<T>
    extends Object
    implements Consumer<Maybe<T>>
    A consumer extension that handles the Maybe concept.

    If the Maybe has a value, it will be passed to the wrapped Consumer, and if it does not, no action will be taken.

    • Method Detail

      • from

        public static <T> Maybe.MaybeConsumer<T> from​(Consumer<T> wrappedConsumer)
        Creates a new Maybe.MaybeConsumer from the given Consumer
        Type Parameters:
        T - The type of the original object being consumed
        Parameters:
        wrappedConsumer - The consumer to wrap
        Returns:
        The wrapped consumer object
      • accept

        public void accept​(Maybe<T> tMaybe)
        Performs this operation on the given argument.
        Specified by:
        accept in interface Consumer<T>
        Parameters:
        tMaybe - the input argument