Interface MatchAccumulator<M,R>
-
- Type Parameters:
M
- mR
- r
public interface MatchAccumulator<M,R>
Class to used to accumulate the individual match results (the results of applying theMatchFunction
) into an object of typeR
. This class provides an interface for clients that in its concept is not entirely unlikeCollector
. Instances of this class, however, are meant to be mutable while collectors are essentially stateless lambda factories. The life cycle of an accumulator (after its creation) spans multiple calls toaccumulate(java.lang.Iterable<M>)
which cause the accumulator instance to update it's internal and hidden state followed by one or more calls tofinish()
which produce a final result of typeR
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
accumulate(Iterable<M> m)
Accumulates theIterable
handed in into the internal state of the instance.R
finish()
Compute and return a result based on the internal state of the instance.
-
-
-
Method Detail
-
accumulate
void accumulate(Iterable<M> m)
Accumulates theIterable
handed in into the internal state of the instance.- Parameters:
m
- and iterable of typeM
-
finish
R finish()
Compute and return a result based on the internal state of the instance. After calling this method, clients should not callaccumulate(java.lang.Iterable<M>)
again. Clients should discard this object after this method has been called. Multiple calls to this method, however, must return the same stable result.- Returns:
- the result
-
-