Iterable wrapper around a Collection that advances
a ProgressBar on each element consumed.
Each call to Iterator#next() on the iterator returned by iterator()
delegates to the underlying collection iterator and immediately invokes
ProgressBar#tick() on the internal progress bar, re-rendering it in place.
This iterable may only be traversed once. A second call to iterator()
throws IllegalStateException. The progress bar total is fixed to the collection
size at construction time.
This class is not thread-safe.
| Modifier and Type | Class and Description |
|---|---|
| private static record |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private final Iterator | |
| pack-priv final ProgressBar | |
| private PrintStream |
| Access | Constructor and Description |
|---|---|
| public | IterableProgressBar(Collection<T>
the collection to iterate over; must not be collection, ProgressBarConfiguration nullthe progress bar configuration to use; must not be configuration)nullConstructs an |
| public | IterableProgressBar(Collection<T>
the collection to iterate over; must not be collection)nullConstructs an |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object o)
Overrides java. Indicates whether some other object is "equal to" this one. |
| public int | |
| public boolean | Returns: true if the progress bar is complete; false otherwiseReturns whether the underlying progress bar has reached its total. |
| public Iterator | Returns: an iterator over the elements of the underlying collectionImplements java. Returns an iterator that advances the internal progress bar on each element consumed. |
| public IterableProgressBar | printStream(PrintStream
the stream to print to; must not be stream)nullPrints the progress bar component to the given |
| public String |
| consumed | back to summary |
|---|---|
| private boolean consumed | |
| iterator | back to summary |
|---|---|
| private final Iterator<T> iterator | |
| progressBar | back to summary |
|---|---|
| pack-priv final ProgressBar progressBar | |
| stream | back to summary |
|---|---|
private PrintStream stream
| |
| IterableProgressBar | back to summary |
|---|---|
| public IterableProgressBar(Collection<T> collection, ProgressBarConfiguration configuration) Constructs an The progress bar total is set to
| |
| IterableProgressBar | back to summary |
|---|---|
| public IterableProgressBar(Collection<T> collection) Constructs an
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| isDone | back to summary |
|---|---|
| public boolean isDone() Returns whether the underlying progress bar has reached its total. This returns
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Returns an iterator that advances the internal progress bar on each element consumed. This method may only be called once. The returned iterator is not reusable and reflects the state of the collection iterator captured at construction time.
| |
| printStream | back to summary |
|---|---|
| public IterableProgressBar Prints the progress bar component to the given
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |
| Modifier and Type | Field and Description |
|---|---|
| private final IterableProgressBar | iterableProgressBar
Record Component accessed by iterableProgressBar(). |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public final int | |
| public boolean | |
| public IterableProgressBar | |
| public T | |
| public final String | toString()
Implements abstract java. Returns a string representation of the record. |
| iterableProgressBar | back to summary |
|---|---|
| private final IterableProgressBar<T> iterableProgressBar Record Component accessed by iterableProgressBar(). | |
| ProgressBarIterator | back to summary |
|---|---|
| private ProgressBarIterator(IterableProgressBar<T> iterableProgressBar) | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| iterableProgressBar | back to summary |
|---|---|
| public IterableProgressBar Record Component getter of iterableProgressBar. | |
| next | back to summary |
|---|---|
| public T next() Implements java. Doc from java. Returns the next element in the iteration.
| |
| toString | back to summary |
|---|---|
| public final String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves. | |