Class FirstOf<T>

  • Type Parameters:
    T - Type of result
    All Implemented Interfaces:
    Scalar<T>

    public final class FirstOf<T>
    extends Object
    implements Scalar<T>
    Find first element in a list that satisfies specified condition.

    There is no thread-safety guarantee.

    Since:
    0.32
    • Constructor Detail

      • FirstOf

        public FirstOf​(Iterable<? extends T> src,
                       T fbck)
        Constructor with default condition (always `true`) and plain fallback.
        Parameters:
        src - Source iterable
        fbck - Fallback used if no value matches
      • FirstOf

        public FirstOf​(Iterable<? extends T> src,
                       Scalar<? extends T> fbck)
        Constructor with default condition (always `true`).
        Parameters:
        src - Source iterable
        fbck - Fallback used if no value matches
      • FirstOf

        public FirstOf​(Func<? super T,​Boolean> cond,
                       Iterable<? extends T> src,
                       Scalar<? extends T> fbck)
        Constructor.
        Parameters:
        cond - Condition for getting the element
        src - Source iterable
        fbck - Fallback used if no value matches
    • Method Detail

      • value

        public T value()
                throws Exception
        Description copied from interface: Scalar
        Convert it to the value.
        Specified by:
        value in interface Scalar<T>
        Returns:
        The value
        Throws:
        Exception - If fails