Payload - The payload typepublic interface IndexedSource<Payload> extends Source<Payload>, ProtectedBidirectionalIterable<Payload>
Source is a linear read-only data structure.
A Source is intended to be used in APIs that want to expose read-only
access to a collection of payload values.
It is, amongst other things, intended as a more expressive replacement for
Collections.unmodifiableList(java.util.List) that prevents
unnecessary runtime exceptions.
| Modifier and Type | Method and Description |
|---|---|
Optional<Integer> |
firstIndexOf(Payload payload)
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 |
getFirst()
Returns the first payload value.
|
Optional<Payload> |
getFirst(Payload reference)
Returns the first occurrences, by
equality,
of the given reference payload value. |
Optional<Payload> |
getFirstMatch(Predicate<? super Payload> predicate)
Returns the first payload value that satisfies the given
Predicate . |
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(boolean reverse)
Returns a
ProtectedBidirectionalIterator. |
Optional<Integer> |
lastIndexOf(Payload payload)
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, getAll, getAllMatches, isEmpty, sizeiteratoriteratorforEach, spliteratorPayload get(int index) throws IndexOutOfBoundsException
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.boolean isFirst(Payload payload) throws NoSuchElementException
first payload value.payload - The payload value to be used.NoSuchElementException - If the given payload value is not contained in this
IndexedSource.Payload getFirst() throws NoSuchElementException
getFirst in interface Source<Payload>NoSuchElementException - If this IndexedSource is
empty.Optional<Payload> getFirst(Payload reference)
equality,
of the given reference payload value.Optional<Payload> getFirstMatch(Predicate<? super Payload> predicate) throws IllegalArgumentException
Predicate .getFirstMatch in interface Source<Payload>predicate - The Predicate to be used.Optional yielding the payload value.IllegalArgumentException - If the given Predicate is null.boolean isLast(Payload payload) throws NoSuchElementException
last payload value.payload - The payload value to be used.NoSuchElementException - If the given payload value is not contained in this
IndexedSource.Payload getLast() throws NoSuchElementException
NoSuchElementException - If this IndexedSource is
empty.Optional<Payload> getLast(Payload reference)
equality,
of the given reference payload value.reference - The reference payload to be used.Optional yielding the payload value.Optional<Payload> getLastMatch(Predicate<? super Payload> predicate) throws IllegalArgumentException
Predicate
.predicate - The Predicate to be used.Optional yielding the payload value.IllegalArgumentException - If the given Predicate is null.Optional<Integer> firstIndexOf(Payload payload)
payload - The payload value to be used.Optional yielding the index.Optional<Integer> firstIndexOfMatch(Predicate<? super Payload> predicate) throws IllegalArgumentException
Predicate.predicate - The Predicate value to be used.Optional yielding the index.IllegalArgumentException - If the given Predicate is null.Optional<Integer> lastIndexOf(Payload payload)
payload - The payload value to be used.Optional yielding the index.Optional<Integer> lastIndexOfMatch(Predicate<? super Payload> predicate) throws IllegalArgumentException
Predicate.predicate - The Predicate value to be used.Optional yielding the index.IllegalArgumentException - If the given Predicate is null.ProtectedBidirectionalIterator<Payload> iterator(boolean reverse)
ProtectedBidirectionalIterator.reverse - 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.