Package com.piketec.tpt.api.util
Class IterableRemoteList<T>
- java.lang.Object
-
- com.piketec.tpt.api.util.IterableRemoteCollection<T>
-
- com.piketec.tpt.api.util.IterableRemoteList<T>
-
- Type Parameters:
T
- the type of elements in this list
- All Implemented Interfaces:
RemoteCollection<T>
,RemoteList<T>
,TptRemote
,RemoteIterable<T>
,java.io.Serializable
,java.lang.Iterable<T>
,java.rmi.Remote
- Direct Known Subclasses:
IterableRemoteIndexedList
public class IterableRemoteList<T> extends IterableRemoteCollection<T> implements RemoteList<T>
A wrapper obejct to provide iterable functionallity for aRemoteList
. Since all methods of aRemote
interface must throw aRemoteException
we cannot implementIterable
directly.
This wrapper has the same interface as aRemoteCollection
and additionally implements theIterable
interface. Since the methods of the latter do not throwRemoteException
this Object cannot be exported as aRemoteObject
.- Author:
- Copyright (c) 2014-2024 Piketec GmbH - MIT License (MIT) - All rights reserved
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description IterableRemoteList(RemoteList<T> delegate)
An iterable view on aRemoteList
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IterableRemoteList<T>
asIterable()
Provides anIterable
view of thisRemoteIterable
.void
delete(int index)
Removes the element at positionindex
from the list.T
get(int index)
Returns the element at positionindex
.int
indexOf(T element)
Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.More formally, returns the lowest index i such that Objects.equals(o, get(i)), or -1 if there is no such index.T
move(int from, int to)
Moves an element from the positionfrom
toto
.-
Methods inherited from class com.piketec.tpt.api.util.IterableRemoteCollection
clear, contains, containsAll, delete, deleteAll, getItems, isEmpty, iterator, remoteIterator, retainAll, size
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.piketec.tpt.api.RemoteCollection
clear, contains, containsAll, delete, deleteAll, getItems, isEmpty, retainAll, size
-
Methods inherited from interface com.piketec.tpt.api.util.RemoteIterable
remoteIterator
-
-
-
-
Constructor Detail
-
IterableRemoteList
public IterableRemoteList(RemoteList<T> delegate)
An iterable view on aRemoteList
. Most likely not needed by API users.- Parameters:
delegate
- The remote list for which an iterable view is needed.- See Also:
RemoteList.asIterable()
-
-
Method Detail
-
get
public T get(int index) throws ApiException, java.lang.IndexOutOfBoundsException, java.rmi.RemoteException
Description copied from interface:RemoteList
Returns the element at positionindex
.- Specified by:
get
in interfaceRemoteList<T>
- Parameters:
index
- The position of the element in the list.- Returns:
- The element that is at this position.
- Throws:
java.lang.IndexOutOfBoundsException
- If theindex < 0
orindex >= getItems().size()
java.rmi.RemoteException
- remote communication problemApiException
-
delete
public void delete(int index) throws ApiException, java.lang.IndexOutOfBoundsException, java.rmi.RemoteException
Description copied from interface:RemoteList
Removes the element at positionindex
from the list.- Specified by:
delete
in interfaceRemoteList<T>
- Parameters:
index
- The position of the item that should be deleted.- Throws:
java.lang.IndexOutOfBoundsException
- If theindex < 0
orindex >= getItems().size()
java.rmi.RemoteException
- remote communication problemApiException
-
move
public T move(int from, int to) throws ApiException, java.lang.IndexOutOfBoundsException, java.rmi.RemoteException
Description copied from interface:RemoteList
Moves an element from the positionfrom
toto
. All elements in this interval will be shifted accordingly such that no gaps exist afterwards and no items will be overwritten.- Specified by:
move
in interfaceRemoteList<T>
- Parameters:
from
- The old position of the element.to
- The new position for the element given byfrom
- Returns:
- Returns a reference to the moved item.
- Throws:
java.lang.IndexOutOfBoundsException
- Ifto < 0
orfrom < 0
orto >= getItems().size()
orfrom >= getItems().size()
java.rmi.RemoteException
- remote communication problemApiException
-
asIterable
public IterableRemoteList<T> asIterable() throws java.rmi.RemoteException
Description copied from interface:RemoteIterable
Provides anIterable
view of thisRemoteIterable
. This normally usesRemoteIterable.remoteIterator()
and wraps the return value into a realIterator
that throwsRuntimeExceptions
instead ofRemoteExceptions
so that this view can be used in for-each loops.- Specified by:
asIterable
in interfaceRemoteCollection<T>
- Specified by:
asIterable
in interfaceRemoteIterable<T>
- Specified by:
asIterable
in interfaceRemoteList<T>
- Overrides:
asIterable
in classIterableRemoteCollection<T>
- Returns:
- an iterable view of this
RemoteIterable
- Throws:
java.rmi.RemoteException
- remote communication problem- See Also:
ApiIterator
-
indexOf
public int indexOf(T element) throws java.rmi.RemoteException, ApiException
Description copied from interface:RemoteList
Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.More formally, returns the lowest index i such that Objects.equals(o, get(i)), or -1 if there is no such index.- Specified by:
indexOf
in interfaceRemoteList<T>
- Parameters:
element
- element to search for- Returns:
- the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element
- Throws:
java.rmi.RemoteException
- remote communication problemApiException
-
-