T - Join element type.C - Context type passed from addInput to join.R - Return type passed from join to to addInput.public abstract class Joiner<T,C,R> extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Joiner.CollectionAdapter<T>
Adapter for collections.
|
static interface |
Joiner.Collector<T>
Collector of objects to join.
|
static class |
Joiner.InputConsumer
Interface to consume inputs in join() method.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Joiner(Joiner.Collector<T>[] inputCollectors,
Class<T> inputType,
boolean outerJoin)
Creates joiner.
|
| Modifier and Type | Method and Description |
|---|---|
List<R> |
addInput(int index,
T input,
C context)
Adds input.
|
void |
addPredicate(Predicate<T,C> predicate)
Adds join predicate.
|
protected abstract void |
endJoin()
This method is invoked after join is finished.
|
protected boolean |
isValidInput(int index,
T input)
This method is invoked for all inputs before joining.
|
protected abstract R |
join(T[] inputs,
C context,
Joiner.InputConsumer consumer,
int activator)
This method is invoked for every combination of valid inputs.
|
protected void |
join(T[] inputs,
int currentIndex,
int inputIndex,
C context,
Joiner.InputConsumer consumer,
Map<C,Map<Extractor<T,? super Boolean,C>,? super Boolean>> cache,
List<R> resultCollector)
This method can be overridden to implement concurrent joining, i.e.
|
protected boolean |
partialJoin(T[] inputs,
C context,
Joiner.InputConsumer consumer,
int index,
int activator)
This method is invoked to validate already joined inputs.
|
void |
reset()
Clears join collections.
|
protected abstract void |
startJoin()
Start join is invoked before join.
|
protected Joiner(Joiner.Collector<T>[] inputCollectors, Class<T> inputType, boolean outerJoin)
inputCollectors - Input collectors.inputType - Input type is required because of erasure of generics and T is needed at runtime.outerJoin - If true, each input addition triggers invocation of join, even if other input collectors
don't have any data.public void addPredicate(Predicate<T,C> predicate)
predicate - protected abstract void startJoin()
protected abstract void endJoin()
public List<R> addInput(int index, T input, C context) throws Exception
index - Input index.input - Input.Exceptionprotected void join(T[] inputs, int currentIndex, int inputIndex, C context, Joiner.InputConsumer consumer, Map<C,Map<Extractor<T,? super Boolean,C>,? super Boolean>> cache, List<R> resultCollector) throws Exception
inputs - currentIndex - inputIndex - context - consumer - cache - resultCollector - Exceptionprotected abstract R join(T[] inputs, C context, Joiner.InputConsumer consumer, int activator) throws Exception
inputs - Inputscontext - Join context passed from addInputconsumer - callback interface to consume inputs.activator - Index of join activator.Exceptionprotected boolean isValidInput(int index, T input)
index - input - protected boolean partialJoin(T[] inputs, C context, Joiner.InputConsumer consumer, int index, int activator) throws Exception
inputs - Inputs array.index - Index of last already joined input.consumer - Callback interface to consume inputs.Exceptionpublic void reset()