Package com.piketec.tpt.api.util
Class IterableRemoteCollection<T>
- java.lang.Object
-
- com.piketec.tpt.api.util.IterableRemoteCollection<T>
-
- Type Parameters:
T
- the type of elements in this collection
- All Implemented Interfaces:
RemoteCollection<T>
,TptRemote
,RemoteIterable<T>
,java.io.Serializable
,java.lang.Iterable<T>
,java.rmi.Remote
- Direct Known Subclasses:
IterableRemoteList
public class IterableRemoteCollection<T> extends java.lang.Object implements RemoteCollection<T>, java.lang.Iterable<T>, java.io.Serializable
A wrapper obejct to provide iterable functionallity for aRemoteCollection
. 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-2021 Piketec GmbH - MIT License (MIT) - All rights reserved
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description IterableRemoteCollection(RemoteCollection<T> delegate)
An iterable view on aRemoteCollection
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IterableRemoteCollection<T>
asIterable()
Provides anIterable
view of thisRemoteIterable
.void
clear()
Remove all elements from this collection.boolean
contains(T o)
Returnstrue
e if this collection contains the specified element.boolean
containsAll(java.util.Collection<? extends T> c)
Returnstrue
if this collection contains all the elements in the given collection.void
delete(T element)
Delete an element from the list.boolean
deleteAll(java.util.Collection<?> c)
Removes all of this collection's elements that are contained in the given collection.java.util.Collection<T>
getItems()
Returns all items of thisRemoteCollection
.boolean
isEmpty()
Returnstrue
if this collection contains no elements.java.util.Iterator<T>
iterator()
RemoteIterator<T>
remoteIterator()
Provides a remote iterator that has the same interface asIterator
but every method can throw aRemoteException
as required by Java RMI.boolean
retainAll(java.util.Collection<?> c)
Removes all of this collection's elements that are not contained in the specified collection.int
size()
Returns the number of elements in this collection.
-
-
-
Constructor Detail
-
IterableRemoteCollection
public IterableRemoteCollection(RemoteCollection<T> delegate)
An iterable view on aRemoteCollection
. Most likely not needed by API users.- Parameters:
delegate
- The remote list for which an iterable view is needed.- See Also:
RemoteCollection.asIterable()
-
-
Method Detail
-
remoteIterator
public RemoteIterator<T> remoteIterator() throws java.rmi.RemoteException
Description copied from interface:RemoteIterable
Provides a remote iterator that has the same interface asIterator
but every method can throw aRemoteException
as required by Java RMI. This method is most likely not relevant for API users but needed forRemoteIterable.asIterable()
.- Specified by:
remoteIterator
in interfaceRemoteIterable<T>
- Returns:
- a remote iterator
- Throws:
java.rmi.RemoteException
- remote communication problem- See Also:
RemoteIterable.asIterable()
-
getItems
public java.util.Collection<T> getItems() throws ApiException, java.rmi.RemoteException
Description copied from interface:RemoteCollection
Returns all items of thisRemoteCollection
. Any change to the returnedCollection
is local and will not be sent to TPT.
If you just want to iterate over the items useRemoteCollection.asIterable()
.- Specified by:
getItems
in interfaceRemoteCollection<T>
- Returns:
- all items of this
RemoteCollection
at once. - Throws:
java.rmi.RemoteException
- remote communication problemApiException
- See Also:
RemoteCollection.asIterable()
-
delete
public void delete(T element) throws ApiException, java.rmi.RemoteException
Description copied from interface:RemoteCollection
Delete an element from the list. This function directly deletes the correspondingelement
in TPT.If multiple
RemoteCollections
refer to the same collection in TPT, the TPT object will be deleted from the collection as soon as this method is called with any of those and the change is reflected in all of them.- Specified by:
delete
in interfaceRemoteCollection<T>
- Parameters:
element
- The element to remove.- Throws:
java.rmi.RemoteException
- remote communication problemApiException
-
iterator
public java.util.Iterator<T> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<T>
-
asIterable
public IterableRemoteCollection<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>
- Returns:
- an iterable view of this
RemoteIterable
- Throws:
java.rmi.RemoteException
- remote communication problem- See Also:
ApiIterator
-
size
public int size() throws java.rmi.RemoteException
Description copied from interface:RemoteCollection
Returns the number of elements in this collection.- Specified by:
size
in interfaceRemoteCollection<T>
- Returns:
- the number of elements in this collection
- Throws:
java.rmi.RemoteException
- remote communication problem
-
isEmpty
public boolean isEmpty() throws java.rmi.RemoteException
Description copied from interface:RemoteCollection
Returnstrue
if this collection contains no elements.- Specified by:
isEmpty
in interfaceRemoteCollection<T>
- Returns:
true
if this collection contains no elements- Throws:
java.rmi.RemoteException
- remote communication problem
-
contains
public boolean contains(T o) throws java.rmi.RemoteException
Description copied from interface:RemoteCollection
Returnstrue
e if this collection contains the specified element.- Specified by:
contains
in interfaceRemoteCollection<T>
- Parameters:
o
- element whose presence in this collection is to be tested- Returns:
true
e if this collection contains the specified element- Throws:
java.rmi.RemoteException
- remote communication problem
-
containsAll
public boolean containsAll(java.util.Collection<? extends T> c) throws java.rmi.RemoteException
Description copied from interface:RemoteCollection
Returnstrue
if this collection contains all the elements in the given collection.- Specified by:
containsAll
in interfaceRemoteCollection<T>
- Parameters:
c
- collection of elements whose presence in this collection is to be tested- Returns:
true
e if this collection contains all the specified elements- Throws:
java.rmi.RemoteException
- remote communication problem
-
deleteAll
public boolean deleteAll(java.util.Collection<?> c) throws java.rmi.RemoteException
Description copied from interface:RemoteCollection
Removes all of this collection's elements that are contained in the given collection.- Specified by:
deleteAll
in interfaceRemoteCollection<T>
- Parameters:
c
- collection containing elements to be removed from this collection- Returns:
true
if this collection was changed as a result of the call- Throws:
java.rmi.RemoteException
- remote communication problem
-
retainAll
public boolean retainAll(java.util.Collection<?> c) throws java.rmi.RemoteException
Description copied from interface:RemoteCollection
Removes all of this collection's elements that are not contained in the specified collection.- Specified by:
retainAll
in interfaceRemoteCollection<T>
- Parameters:
c
- collection containing elements to be retained in this collection- Returns:
true
if this collection was changed as a result of the call- Throws:
java.rmi.RemoteException
- remote communication problem
-
clear
public void clear() throws java.rmi.RemoteException
Description copied from interface:RemoteCollection
Remove all elements from this collection.- Specified by:
clear
in interfaceRemoteCollection<T>
- Throws:
java.rmi.RemoteException
- remote communication problem
-
-