E - the type of elements in this listpublic final class ListIndexProxy<E> extends AbstractNativeProxy implements ListIndex<E>
This list implementation does not permit null elements.
The "destructive" methods of the list, i.e., those that change its contents,
are specified to throw UnsupportedOperationException if
this list has been created with a read-only database view.
All method arguments are non-null by default.
This class is not thread-safe and and its instances shall not be shared between threads.
When the view goes out of scope, this list is destroyed. Subsequent use of the closed list
is prohibited and will result in IllegalStateException.
ViewnativeHandle| Modifier and Type | Method and Description |
|---|---|
void |
add(T e)
Adds a new element to the end of the list.
|
void |
addAll(Collection<? extends T> elements)
Adds all elements from the specified collection to this list.
|
void |
clear()
Clears the list.
|
T |
get(long index)
Returns the element at the given index.
|
IndexAddress |
getAddress()
Returns the index address: its unique identifier in the database.
|
T |
getLast()
Returns the last element of the list.
|
boolean |
isEmpty()
Returns true if the list is empty, false — otherwise.
|
Iterator<T> |
iterator()
Returns an iterator over the elements of the list.
|
static <E> ListIndexProxy<E> |
newInGroupUnsafe(String groupName,
byte[] listId,
View view,
com.exonum.binding.common.serialization.Serializer<E> serializer)
Creates a new list in a collection group
with the given name.
|
static <E extends com.google.protobuf.MessageLite> |
newInstance(String name,
View view,
Class<E> elementType)
Creates a new ListIndexProxy storing protobuf messages.
|
static <E> ListIndexProxy<E> |
newInstance(String name,
View view,
com.exonum.binding.common.serialization.Serializer<E> serializer)
Creates a new ListIndexProxy.
|
E |
removeLast()
Removes the last element of the list and returns it.
|
void |
set(long index,
T e)
Replaces the element at the given index of the list with the specified element.
|
long |
size()
Returns the number of elements in the list.
|
Stream<T> |
stream()
Returns a stream of elements in this list.
|
String |
toString() |
void |
truncate(long newSize)
Truncates the list, reducing its size to
newSize. |
getNativeHandle, isValidHandleclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitadd, addAll, clear, get, getLast, isEmpty, iterator, set, size, streamgetAddress, getNameforEach, spliteratorpublic static <E extends com.google.protobuf.MessageLite> ListIndexProxy<E> newInstance(String name, View view, Class<E> elementType)
E - the type of elements in this list; must be a protobuf message
that has a public static #parseFrom(byte[]) methodname - a unique alphanumeric non-empty identifier of this list in the underlying storage:
[a-zA-Z0-9_]view - a database view. Must be valid.
If a view is read-only, "destructive" operations are not permitted.elementType - the class of an element-protobuf messageIllegalStateException - if the view is not validIllegalArgumentException - if the name is emptypublic static <E> ListIndexProxy<E> newInstance(String name, View view, com.exonum.binding.common.serialization.Serializer<E> serializer)
E - the type of elements in this listname - a unique alphanumeric non-empty identifier of this list in the underlying storage:
[a-zA-Z0-9_]view - a database view. Must be valid.
If a view is read-only, "destructive" operations are not permitted.serializer - a serializer of elementsIllegalStateException - if the view is not validIllegalArgumentException - if the name is emptyStandardSerializerspublic static <E> ListIndexProxy<E> newInGroupUnsafe(String groupName, byte[] listId, View view, com.exonum.binding.common.serialization.Serializer<E> serializer)
See a caveat on index identifiers.
E - the type of elements in this listgroupName - a name of the collection grouplistId - an identifier of this collection in the group, see the caveatsview - a database viewserializer - a serializer of list elementsIllegalStateException - if the view is not validIllegalArgumentException - if the name or index id is emptyStandardSerializerspublic E removeLast()
NoSuchElementException - if the list is emptyIllegalStateException - if this list is not validUnsupportedOperationException - if this list is read-onlypublic void truncate(long newSize)
newSize.
If newSize < size(), keeps the first newSize elements, removing the rest.
If newSize >= size(), has no effect.
newSize - the maximum number of elements to keepIllegalArgumentException - if the new size is negativeIllegalStateException - if this list is not validUnsupportedOperationException - if this list is read-onlypublic final void add(T e)
ListIndexpublic void addAll(Collection<? extends T> elements)
ListIndexIf the collection contains an invalid element, this list is not modified.
public final void set(long index,
T e)
ListIndexpublic final T get(long index)
ListIndexpublic final T getLast()
ListIndexpublic final void clear()
ListIndexpublic final boolean isEmpty()
ListIndexpublic final long size()
ListIndexpublic final Iterator<T> iterator()
ListIndexpublic Stream<T> stream()
ListIndexpublic IndexAddress getAddress()
StorageIndexgetAddress in interface StorageIndexCopyright © 2019 Exonum. All rights reserved.