public abstract class SplitProcessor<S extends Splittable<S>>
extends java.lang.Object
Instances of this class perform a similar function to that implemented in the Stream class from the Java 8 Streams framework. There is much less functionality and cleverness here, but the behaviour is predictable and permits external iteration rather than imposing internal iteration.
Modifier | Constructor and Description |
---|---|
protected |
SplitProcessor(java.lang.String name)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
abstract <A> A |
collect(SplitCollector<S,A> collector,
S content)
Collects content from a splittable object into an accumulator,
as defined by a provided collector.
|
static <S extends Splittable<S>> |
createBasicParallelProcessor(SplitPolicy policy)
Returns a SplitProcessor instance that works in parallel,
with one accumulator created for every forked subtask.
|
static <S extends Splittable<S>> |
createPoolParallelProcessor(SplitPolicy policy)
Returns a SplitProcessor instance that works in parallel,
with a pool of reusable accumulators shared by forked subtasks.
|
static <S extends Splittable<S>> |
createSequentialProcessor()
Returns a SplitProcessor instance that performs sequential processing.
|
static <S extends Splittable<S>> |
createStandardProcessor(SplitPolicy policy,
boolean isPool)
Returns a suitable processor instance.
|
java.lang.String |
toString() |
abstract boolean |
willAttemptSplit(S content)
Indicates whether this processor will attempt to split the given
splittable object when processing it.
|
protected SplitProcessor(java.lang.String name)
name
- name of this instancepublic abstract boolean willAttemptSplit(S content)
content
- splittable objectpublic abstract <A> A collect(SplitCollector<S,A> collector, S content)
collector
- defines collection semanticscontent
- input datapublic java.lang.String toString()
toString
in class java.lang.Object
public static <S extends Splittable<S>> SplitProcessor<S> createSequentialProcessor()
public static <S extends Splittable<S>> SplitProcessor<S> createBasicParallelProcessor(SplitPolicy policy)
policy
- parallel execution policy, or null for defaultpublic static <S extends Splittable<S>> SplitProcessor<S> createPoolParallelProcessor(SplitPolicy policy)
policy
- parallel execution policy, or null for defaultpublic static <S extends Splittable<S>> SplitProcessor<S> createStandardProcessor(SplitPolicy policy, boolean isPool)
createSequentialProcessor
,
createBasicParallelProcessor
or
createPoolParallelProcessor
,
depending on its arguments.policy
- parallel execution policy, or null for defaultisPool
- true to prefer pooling