Payload - The payload type.public abstract class AbstractIndexedSource<Payload> extends AbstractSource<Payload> implements IndexedSource<Payload>
AbstractIndexedSource is an abstract base implementation of a
IndexedSource.| Constructor and Description |
|---|
AbstractIndexedSource()
Creates a new
AbstractIndexedSource. |
| Modifier and Type | Method and Description |
|---|---|
protected abstract Payload |
doGet(int index)
Returns a payload value at the given index.
|
protected Payload |
doGetFirst()
Returns the first (i.e.
|
protected abstract ProtectedBidirectionalIterator<Payload> |
doIterator(boolean reverse)
Returns a
ProtectedBidirectionalIterator. |
Optional<Integer> |
firstIndexOf(Payload reference)
Returns index, of the first occurrence, by
Object#equals(Object) equality, of the given reference payload
value.
|
Optional<Integer> |
firstIndexOfMatch(Predicate<? super Payload> predicate)
Returns index, of the first occurrence of a payload value that satisfies
the given
Predicate. |
Payload |
get(int index)
Returns the payload value at the given index.
|
Payload |
getLast()
Returns the last payload value.
|
Optional<Payload> |
getLast(Payload reference)
Returns the first occurrences, by
equality,
of the given reference payload value. |
Optional<Payload> |
getLastMatch(Predicate<? super Payload> predicate)
Returns the last payload value that satisfies the given
Predicate
. |
boolean |
isFirst(Payload payload)
Returns whether the given payload value is the
first payload value. |
boolean |
isLast(Payload payload)
Returns whether the given payload value is the
last payload value. |
ProtectedBidirectionalIterator<Payload> |
iterator()
Returns a
ProtectedIterator. |
ProtectedBidirectionalIterator<Payload> |
iterator(boolean reverse)
Returns a
ProtectedBidirectionalIterator. |
Optional<Integer> |
lastIndexOf(Payload reference)
Returns index, of the last occurrence, by
Object#equals(Object) equality, of the given reference payload
value.
|
Optional<Integer> |
lastIndexOfMatch(Predicate<? super Payload> predicate)
Returns index, of the last occurrence of a payload value that satisfies
the given
Predicate. |
contains, containsAll, containsAll, containsMatch, createPredicate, firstIndexOf, getAll, getAllMatches, getFirst, getFirst, getFirstMatch, isEmpty, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetFirst, getFirst, getFirstMatchcontains, containsAll, containsAll, containsMatch, getAll, getAllMatches, isEmpty, sizeforEach, spliteratorpublic AbstractIndexedSource()
AbstractIndexedSource.public final Payload get(int index) throws IndexOutOfBoundsException
IndexedSourceget in interface IndexedSource<Payload>index - The index to be used.IndexOutOfBoundsException - If the given index is negative or if the given index is
larger or equal to the size of
this IndexedSource.protected abstract Payload doGet(int index)
index - The index to be used, which is guaranteed to be not negative
and not larger then or equal to the
size of this
AbstractIndexedSource.public final boolean isFirst(Payload payload) throws NoSuchElementException
IndexedSourcefirst payload value.isFirst in interface IndexedSource<Payload>payload - The payload value to be used.NoSuchElementException - If the given payload value is not contained in this
IndexedSource.protected final Payload doGetFirst()
AbstractSourceiterator) payload value, which is guaranteed to
exist.doGetFirst in class AbstractSource<Payload>public final boolean isLast(Payload payload) throws NoSuchElementException
IndexedSourcelast payload value.isLast in interface IndexedSource<Payload>payload - The payload value to be used.NoSuchElementException - If the given payload value is not contained in this
IndexedSource.public final Payload getLast() throws NoSuchElementException
IndexedSourcegetLast in interface IndexedSource<Payload>NoSuchElementException - If this IndexedSource is
empty.public final Optional<Payload> getLast(Payload reference)
IndexedSourceequality,
of the given reference payload value.getLast in interface IndexedSource<Payload>reference - The reference payload to be used.Optional yielding the payload value.public final Optional<Payload> getLastMatch(Predicate<? super Payload> predicate) throws IllegalArgumentException
IndexedSourcePredicate
.getLastMatch in interface IndexedSource<Payload>predicate - The Predicate to be used.Optional yielding the payload value.IllegalArgumentException - If the given Predicate is null.public final Optional<Integer> firstIndexOf(Payload reference) throws NoSuchElementException
IndexedSourcefirstIndexOf in interface IndexedSource<Payload>reference - The payload value to be used.Optional yielding the index.NoSuchElementExceptionpublic final Optional<Integer> firstIndexOfMatch(Predicate<? super Payload> predicate) throws IllegalArgumentException, NoSuchElementException
IndexedSourcePredicate.firstIndexOfMatch in interface IndexedSource<Payload>predicate - The Predicate value to be used.Optional yielding the index.IllegalArgumentException - If the given Predicate is null.NoSuchElementExceptionpublic final Optional<Integer> lastIndexOf(Payload reference) throws NoSuchElementException
IndexedSourcelastIndexOf in interface IndexedSource<Payload>reference - The payload value to be used.Optional yielding the index.NoSuchElementExceptionpublic final Optional<Integer> lastIndexOfMatch(Predicate<? super Payload> predicate) throws IllegalArgumentException, NoSuchElementException
IndexedSourcePredicate.lastIndexOfMatch in interface IndexedSource<Payload>predicate - The Predicate value to be used.Optional yielding the index.IllegalArgumentException - If the given Predicate is null.NoSuchElementExceptionpublic final ProtectedBidirectionalIterator<Payload> iterator()
ProtectedIterableProtectedIterator.iterator in interface Iterable<Payload>iterator in interface BidirectionalIterable<Payload>iterator in interface ProtectedBidirectionalIterable<Payload>iterator in interface ProtectedIterable<Payload>ProtectedIterator.public final ProtectedBidirectionalIterator<Payload> iterator(boolean reverse)
IndexedSourceProtectedBidirectionalIterator.iterator in interface IndexedSource<Payload>reverse - Whether to return a ProtectedBidirectionalIterator
that iterates this indexed source in reverse.ProtectedBidirectionalIterator.protected abstract ProtectedBidirectionalIterator<Payload> doIterator(boolean reverse)
ProtectedBidirectionalIterator.reverse - The initial index to be used. Whether to return a
ProtectedBidirectionalIterator that iterates this
indexed source in reverse.ProtectedBidirectionalIterator.Copyright © 2016–2017 Markenwerk – Gesellschaft für markenbildende Maßnahmen mbH. All rights reserved.