java.lang.Object
org.refcodes.generator.AbstractCounterComposite<T>
- Type Parameters:
T
- the generic type of the elements being generated.
- All Implemented Interfaces:
Iterator<T>
,Counter<T>
,Generator<T>
,org.refcodes.mixin.ChildrenAccessor<Counter<T>[]>
,org.refcodes.mixin.Resetable
- Direct Known Subclasses:
IdCounterComposite
public abstract class AbstractCounterComposite<T>
extends Object
implements Counter<T>, org.refcodes.mixin.ChildrenAccessor<Counter<T>[]>
The
AbstractCounterComposite
combines several Counter
instances which to use when generating data by daisy chaining the provided
generator instances (end of counter 1 increases counter 2, end of counter 2
increases counter 3, ..., end of counter n-1 increases counter n, the end of
a counter is determined with hasNext()
and a counter is increased by
Generator.next()
).-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.mixin.ChildrenAccessor
org.refcodes.mixin.ChildrenAccessor.ChildrenBuilder<T extends Object,
B extends org.refcodes.mixin.ChildrenAccessor.ChildrenBuilder<T, B>>, org.refcodes.mixin.ChildrenAccessor.ChildrenMutator<T extends Object>, org.refcodes.mixin.ChildrenAccessor.ChildrenProperty<T extends Object> -
Constructor Summary
ConstructorDescriptionAbstractCounterComposite
(Counter<T>... aCounters) Constructs aAbstractCounterComposite
daisy chaining the providedCounter
instances. -
Method Summary
Modifier and TypeMethodDescriptionprotected T[]
Returns the current actual counters' state (an individual value for each counter in the returned array as of the order the counters have been added).boolean
hasNext()
Tests whether theGenerator
is capable of generating aGenerator.next()
item.protected T[]
Returns theGenerator.next()
value as of the individual underlyingAlphabetCounter
instances (an individual value for each counter in the returned array as of the order the counters have been added).void
reset()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
AbstractCounterComposite
Constructs aAbstractCounterComposite
daisy chaining the providedCounter
instances.- Parameters:
aCounters
- TheCounter
instances to be daisy chained.
-
-
Method Details
-
hasNext
public boolean hasNext()Tests whether theGenerator
is capable of generating aGenerator.next()
item. -
reset
public void reset()- Specified by:
reset
in interfaceorg.refcodes.mixin.Resetable
-
getChildren
- Specified by:
getChildren
in interfaceorg.refcodes.mixin.ChildrenAccessor<T>
-
actualCounters
Returns the current actual counters' state (an individual value for each counter in the returned array as of the order the counters have been added).- Returns:
- The current actual counters' state.
-
nextCounters
Returns theGenerator.next()
value as of the individual underlyingAlphabetCounter
instances (an individual value for each counter in the returned array as of the order the counters have been added).- Returns:
- The according array with the counters' individual next values.
- Throws:
NoSuchElementException
- in case no more elements can be generated by the encapsulated counters.
-