java.lang.Object
org.refcodes.generator.SeriesMonitorDecorator<T>
- Type Parameters:
T
- the generic type of the elements being generated.
- All Implemented Interfaces:
Iterator<T>
,Generator<T>
,SeriesMonitor<T>
,org.refcodes.mixin.Clearable
The
SeriesMonitorDecorator
decorates a Generator
with means
to monitor the last fully processed (completed) ID of the series of generated
IDs with all preceding generated IDs also being fully processed (completed):
All IDs till the last fully processed (completed) ID have been processed. Any
IDs being processed after this last fully processed (completed) ID are not
taken into account as between them and the the last fully processed
(completed) ID there are gaps of uncompleted (not yet finished) IDs (which
were not filled up yet e.g. as of a multi threaded environment).-
Constructor Summary
ConstructorDescriptionSeriesMonitorDecorator
(Generator<T> aDecoratee) Constructs theSeriesMonitorDecorator
decorating the providedGenerator
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the list of unprocessed IDs.void
forEachRemaining
(Consumer<? super T> aAction) boolean
hasNext()
Tests whether theGenerator
is capable of generating aGenerator.next()
item.Returns the last ID of fully processed IDs in the series of generated IDs.boolean
markAsProcessed
(T aId) Marks a ID previously generated usingGenerator.next()
as being processed, the last ID of fully processed IDs in the series of generated IDs can be identified using theSeriesMonitor.lastProcessed()
method.next()
Generates a next item.void
remove()
-
Constructor Details
-
SeriesMonitorDecorator
Constructs theSeriesMonitorDecorator
decorating the providedGenerator
.- Parameters:
aDecoratee
- TheGenerator
to be decorated.
-
-
Method Details
-
remove
public void remove() -
hasNext
public boolean hasNext()Tests whether theGenerator
is capable of generating aGenerator.next()
item. -
next
Generates a next item. -
forEachRemaining
- Specified by:
forEachRemaining
in interfaceIterator<T>
-
markAsProcessed
Marks a ID previously generated usingGenerator.next()
as being processed, the last ID of fully processed IDs in the series of generated IDs can be identified using theSeriesMonitor.lastProcessed()
method.- Specified by:
markAsProcessed
in interfaceSeriesMonitor<T>
- Parameters:
aId
- The ID to be marked as processed.- Returns:
- True in case the ID has not been marked before as processed, false if the ID has never been generated or has already been Marked as processed.
-
lastProcessed
Returns the last ID of fully processed IDs in the series of generated IDs.- Specified by:
lastProcessed
in interfaceSeriesMonitor<T>
- Returns:
- The according ID or null if nine ID has yet been marked as being processed.
-
clear
public void clear()Clears the list of unprocessed IDs.- Specified by:
clear
in interfaceorg.refcodes.mixin.Clearable
-