public final class LineProcessors extends Object
LineProcessor
classes.
Note that main difference between InputProcessor
and
LineProcessor
is that LineProcessor always process whole lines.
Modifier and Type | Method and Description |
---|---|
static LineProcessor |
patternWaiting(Pattern pattern,
CountDownLatch latch)
Returns the processor that will wait for the line matching the pattern,
decreasing the latch when such line appears for the first time.
|
static LineProcessor |
printing(PrintWriter out)
Returns the processor printing all lines passed for processing to
the given output writer.
|
static LineProcessor |
proxy(LineProcessor... processors)
Returns the processor acting as a proxy.
|
@NonNull public static LineProcessor proxy(@NonNull LineProcessor... processors)
Any action taken on this processor is distributed to all processors passed as arguments in the same order as they were passed to this method.
Returned processor is not thread safe.
processors
- processor to which the actions will be distributed@NonNull public static LineProcessor printing(@NonNull PrintWriter out)
Processor closes the output writer on InputProcessor.close()
.
Returned processor is not thread safe.
out
- where to print received lines@NonNull public static LineProcessor patternWaiting(@NonNull Pattern pattern, @NonNull CountDownLatch latch)
Reset action on the returned processor is noop.
Returned processor is thread safe.
pattern
- pattern that line must match in order decrease the latchlatch
- latch to decrease when the line matching the pattern appears
for the first time