Class ConditionalCollector<T,​A,​R>

  • Type Parameters:
    T - the type of input elements to the reduction operation
    A - the mutable accumulation type of the reduction operation (often hidden as an implementation detail)
    R - the result type of the reduction operation
    All Implemented Interfaces:
    Task.Collector<T,​List<T>,​R>, com.tangosol.io.ExternalizableLite, com.tangosol.io.pof.PortableObject, Serializable

    public class ConditionalCollector<T,​A,​R>
    extends Object
    implements Task.Collector<T,​List<T>,​R>, com.tangosol.io.pof.PortableObject
    A Task.Collector that conditionally collects values based on the available result.
    Since:
    21.12
    Author:
    bo
    See Also:
    Serialized Form
    • Field Detail

      • m_predicate

        protected com.tangosol.util.function.Remote.Predicate<? super Iterator<T>> m_predicate
        The Remote.Predicate to determine when results can be collected.
      • m_defaultResult

        protected R m_defaultResult
        The default result to return when the Remote.Predicate is not satisfied.
    • Constructor Detail

      • ConditionalCollector

        public ConditionalCollector()
        For serialization.
      • ConditionalCollector

        public ConditionalCollector​(com.tangosol.util.function.Remote.Predicate<? super Iterator<T>> predicate,
                                    Task.Collector<? super T,​A,​R> collector,
                                    R defaultResult)
        Constructs a ConditionalCollector.
        Parameters:
        predicate - the Remote.Predicate to determine if collection should occur
        collector - the Task.Collector to use when the Remote.Predicate is satisfied
        defaultResult - the default result to use when the Remote.Predicate is not satisfied
    • Method Detail

      • finishable

        public com.tangosol.util.function.Remote.Predicate<List<T>> finishable()
        Description copied from interface: Task.Collector
        A Remote.Predicate to determine if a result container can be finished early avoiding further accumulation of results using the container.

        Should there be no further results to accumulate, finishing the result container with the Task.Collector.finisher() will occur regardless of the result returned by the Remote.Predicate.

        Specified by:
        finishable in interface Task.Collector<T,​A,​R>
        Returns:
        a Remote.Predicate
      • finisher

        public Function<List<T>,​R> finisher()
        Description copied from interface: Task.Collector
        Perform the final transformation from the intermediate accumulation type A to the final result type R.
        Specified by:
        finisher in interface Task.Collector<T,​A,​R>
        Returns:
        a function which transforms the intermediate result to the final result
      • supplier

        public Supplier<List<T>> supplier()
        Description copied from interface: Task.Collector
        A function that creates and returns a new mutable result container.
        Specified by:
        supplier in interface Task.Collector<T,​A,​R>
        Returns:
        a function which returns a new mutable result container
      • readExternal

        public void readExternal​(DataInput in)
                          throws IOException
        Specified by:
        readExternal in interface com.tangosol.io.ExternalizableLite
        Throws:
        IOException
      • writeExternal

        public void writeExternal​(DataOutput out)
                           throws IOException
        Specified by:
        writeExternal in interface com.tangosol.io.ExternalizableLite
        Throws:
        IOException
      • readExternal

        public void readExternal​(com.tangosol.io.pof.PofReader in)
                          throws IOException
        Specified by:
        readExternal in interface com.tangosol.io.pof.PortableObject
        Throws:
        IOException
      • writeExternal

        public void writeExternal​(com.tangosol.io.pof.PofWriter out)
                           throws IOException
        Specified by:
        writeExternal in interface com.tangosol.io.pof.PortableObject
        Throws:
        IOException