com.vaadin.collaborationengine.
Interface CollaborationList
All Superinterfaces:
A list that is shared between multiple users. List instances can be retrieved
through a TopicConnection
. Changes performed by one user will be
delivered as events to subscribers defined by other users.
Since:
3.1
Author:
Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptionapply
(ListOperation operation) Performs the given list operation.
Gets the topic connection which is used to propagate changes to this list.
Gets the optional expiration timeout of this list.
<T> T
Gets the list item identifier by the given key as instance of the given type reference.
<T> T
Gets the list item identifier by the given key as instance of the given class.
<T> List<T>
getItems
(com.fasterxml.jackson.core.type.TypeReference<T> type) Gets the list items as instances of the given type reference.
<T> List<T>
Gets the list items as instances of the given class.
getKeys()
Gets the keys for all the items on the list.
default ListOperationResult<Boolean>
insertAfter
(ListKey key, Object item) Inserts the given item just after the given key location.
default ListOperationResult<Boolean>
insertBefore
(ListKey key, Object item) Inserts the given item just before the given key location.
default ListOperationResult<Void>
insertFirst
(Object item) Inserts the given item as the first item of the list.
default ListOperationResult<Void>
insertLast
(Object item) Inserts the given item as the last item of the list.
default CompletableFuture<Boolean>
Moves the second given key just after the first given key location.
default CompletableFuture<Boolean>
moveBefore
(ListKey key, ListKey keyToMove) Moves the second given key just before the first given key location.
default CompletableFuture<Boolean>
Removes the value for the item identified by the given key.
default CompletableFuture<Boolean>
Sets a new value for the item identified by the given key.
void
setExpirationTimeout
(Duration expirationTimeout) Sets the expiration timeout of this list.
subscribe
(ListSubscriber subscriber) Subscribes to changes to this list.
-
Method Details
-
getItems
Gets the list items as instances of the given class.
Type Parameters:
T
- the type of the class given as the argumentParameters:
type
- the expected type of the itemsReturns:
a list of the items
Throws:
JsonConversionException
- if one or more values in the list cannot be converted to an instance of the given class -
getItems
Gets the list items as instances of the given type reference.
Type Parameters:
T
- the type of the reference given as the argumentParameters:
type
- the reference of the expected type of the itemsReturns:
a list of the items
Throws:
JsonConversionException
- if one or more values in the list cannot be converted to an instance of the given type reference -
getItem
Gets the list item identifier by the given key as instance of the given class.
Type Parameters:
T
- the type of the value fromtype
parameter, e.g.String
Parameters:
key
- the key of the requested item, notnull
type
- the expected type of the item, notnull
Returns:
the requested item
Throws:
JsonConversionException
- if the value in the list cannot be converted to an instance of the given classSince:
4.1
-
getItem
Gets the list item identifier by the given key as instance of the given type reference.
Type Parameters:
T
- the type reference of the value fromtype
parameter, e.g.List
Parameters:
key
- the key of the requested item, notnull
type
- the expected type reference of the item, notnull
Returns:
the requested item
Throws:
JsonConversionException
- if the value in the list cannot be converted to an instance of the given classSince:
4.1
-
getKeys
Gets the keys for all the items on the list.
Returns:
the keys
Since:
4.1
-
apply
Performs the given list operation. The operation contains the value, its position and other requirements. If any of the conditions are not met, the operation may fail (see
ListOperationResult
).Parameters:
operation
- the list operation, notnull
Returns:
the result of the operation, not
null
-
insertFirst
Inserts the given item as the first item of the list.
Parameters:
item
- the item, notnull
Returns:
the result of the operation, not
null
-
insertLast
Inserts the given item as the last item of the list.
Parameters:
item
- the item, notnull
Returns:
the result of the operation, not
null
Since:
4.1
-
insertBefore
Inserts the given item just before the given key location.
Parameters:
key
- the position key, notnull
item
- the item, notnull
Returns:
the result of the operation, not
null
-
insertAfter
Inserts the given item just after the given key location.
Parameters:
key
- the position key, notnull
item
- the item, notnull
Returns:
the result of the operation, not
null
-
moveBefore
Moves the second given key just before the first given key location.
Parameters:
key
- the position key, notnull
keyToMove
- the key to move, notnull
Returns:
a completable future that is resolved when the operation has completed, not
null
-
moveAfter
Moves the second given key just after the first given key location.
Parameters:
key
- the position key, notnull
keyToMove
- the key to move, notnull
Returns:
a completable future that is resolved when the operation has completed, not
null
-
set
Sets a new value for the item identified by the given key.
Parameters:
key
- the item key, notnull
value
- the new value of the itemReturns:
the result of the operation, not
null
Since:
4.1
-
remove
Removes the value for the item identified by the given key.
Parameters:
key
- the item key, notnull
Returns:
the result of the operation, not
null
-
subscribe
Subscribes to changes to this list. When subscribing, the subscriber will receive an event for each item already in the list.
Parameters:
subscriber
- the subscriber to use, notnull
Returns:
a handle that can be used for removing the subscription, not
null
-
getConnection
TopicConnection getConnection()Gets the topic connection which is used to propagate changes to this list.
Returns:
the topic connection used by this list, not
null
-
getExpirationTimeout
Gets the optional expiration timeout of this list. An empty
Optional
is returned if no timeout is set, which means the list is not cleared when there are no connected users to the related topic (this is the default).Specified by:
getExpirationTimeout
in interfaceHasExpirationTimeout
Returns:
the expiration timeout
-
setExpirationTimeout
Sets the expiration timeout of this list. If set, the list content is cleared when
expirationTimeout
has passed after the last connection to the topic this list belongs to is closed. If set tonull
, the timeout is cancelled.Specified by:
setExpirationTimeout
in interfaceHasExpirationTimeout
Parameters:
expirationTimeout
- the expiration timeout
-