com.vaadin.collaborationengine.
Class ListOperation
- java.lang.Object
-
- com.vaadin.collaborationengine.ListOperation
-
public class ListOperation extends Object
A list operation providing details such as the operation type, related properties and conditions that should be met for the operation to succeed.
Author:
Vaadin Ltd
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ListOperation.OperationType
-
Method Summary
All Methods Modifier and Type Method Description static ListOperation
delete(ListKey key)
Creates a list operation to delete the value at the position specified by the given key.
ListOperation
ifEmpty()
Adds a condition that requires the list to be empty.
ListOperation
ifFirst(ListKey key)
Adds a condition that requires the specified
key
to be the first in the list.ListOperation
ifLast(ListKey key)
Adds a condition that requires the specified
key
to be the last in the list.ListOperation
ifNext(ListKey key, ListKey nextKey)
Adds a condition that requires the specified
nextKey
to be right after the specifiedkey
when the operation is applied.ListOperation
ifNotEmpty()
Adds a condition that requires the list not to be empty.
ListOperation
ifPrev(ListKey key, ListKey prevKey)
Adds a condition that requires the specified
prevKey
to be right before the specifiedkey
when the operation is applied.ListOperation
ifValue(ListKey key, Object value)
Add a condition that requires the specified
key
to have the specifiedvalue
.static ListOperation
insertAfter(ListKey after, Object value)
Creates a list operation to insert the given value just after the position specified by the given key.
static ListOperation
insertBefore(ListKey before, Object value)
Creates a list operation to insert the given value just before the position specified by the given key.
static ListOperation
insertBetween(ListKey prev, ListKey next, Object value)
Creates a list operation to insert the given value between the positions specified by the given keys.
static ListOperation
insertFirst(Object value)
Creates a list operation to insert the given value as the first item of the list.
static ListOperation
insertLast(Object value)
Creates a list operation to insert the given value as the last item of the list.
static ListOperation
moveAfter(ListKey after, ListKey entry)
Creates a list operation to move the given entry to just after the position specified by the given key.
static ListOperation
moveBefore(ListKey before, ListKey entry)
Creates a list operation to move the given entry to just before the position specified by the given key.
static ListOperation
moveBetween(ListKey prev, ListKey next, ListKey entry)
Creates a list operation to move the given entry between the positions specified by the given keys.
static ListOperation
set(ListKey key, Object value)
Creates a list operation to set the given value at the position specified by the given key.
ListOperation
withScope(EntryScope scope)
Sets the scope of the item affected by this operation.
-
-
-
Method Detail
-
insertFirst
public static ListOperation insertFirst(Object value)
Creates a list operation to insert the given value as the first item of the list.
Parameters:
value
- the value, notnull
Returns:
the list operation, not
null
-
insertLast
public static ListOperation insertLast(Object value)
Creates a list operation to insert the given value as the last item of the list.
Parameters:
value
- the value, notnull
Returns:
the list operation, not
null
-
insertBefore
public static ListOperation insertBefore(ListKey before, Object value)
Creates a list operation to insert the given value just before the position specified by the given key.
Parameters:
before
- the position key, notnull
value
- the value, notnull
Returns:
the list operation, not
null
-
insertAfter
public static ListOperation insertAfter(ListKey after, Object value)
Creates a list operation to insert the given value just after the position specified by the given key.
Parameters:
after
- the position key, notnull
value
- the value, notnull
Returns:
the list operation, not
null
-
insertBetween
public static ListOperation insertBetween(ListKey prev, ListKey next, Object value)
Creates a list operation to insert the given value between the positions specified by the given keys. If the given keys are not adjacent, the operation will fail.
Parameters:
prev
- the position of the previous item, notnull
next
- the position of the next item, notnull
value
- the value, notnull
Returns:
the list operation, not
null
-
moveBefore
public static ListOperation moveBefore(ListKey before, ListKey entry)
Creates a list operation to move the given entry to just before the position specified by the given key.
Parameters:
before
- the position key, notnull
entry
- the entry key to move, notnull
Returns:
the list operation, not
null
-
moveAfter
public static ListOperation moveAfter(ListKey after, ListKey entry)
Creates a list operation to move the given entry to just after the position specified by the given key.
Parameters:
after
- the position key, notnull
entry
- the entry key to move, notnull
Returns:
the list operation, not
null
-
moveBetween
public static ListOperation moveBetween(ListKey prev, ListKey next, ListKey entry)
Creates a list operation to move the given entry between the positions specified by the given keys. If the given keys are not adjacent, the operation will fail.
Parameters:
prev
- the position of the previous item, notnull
next
- the position of the next item, notnull
entry
- the entry key to move, notnull
Returns:
the list operation, not
null
-
set
public static ListOperation set(ListKey key, Object value)
Creates a list operation to set the given value at the position specified by the given key. By default, the value will be set as topic scope.
Parameters:
key
- the position key, notnull
value
- the valueReturns:
the list operation, not
null
-
delete
public static ListOperation delete(ListKey key)
Creates a list operation to delete the value at the position specified by the given key.
Parameters:
key
- the position key, notnull
Returns:
the list operation, not
null
-
withScope
public ListOperation withScope(EntryScope scope)
Sets the scope of the item affected by this operation. If not set, the default scope will be
EntryScope.TOPIC
. Values withEntryScope.CONNECTION
scope will be automatically removed once the connection to the topic which created them is deactivated.Parameters:
scope
- the scope, notnull
Returns:
this operation, not
null
-
ifNext
public ListOperation ifNext(ListKey key, ListKey nextKey)
Adds a condition that requires the specified
nextKey
to be right after the specifiedkey
when the operation is applied. Anull
nextKey
can be used to represent the tail of the list.Parameters:
key
- the reference key, notnull
nextKey
- the required key, ornull
to represent the tail of the listReturns:
this operation, not
null
-
ifLast
public ListOperation ifLast(ListKey key)
Adds a condition that requires the specified
key
to be the last in the list.Parameters:
key
- the key, notnull
Returns:
this operation, not
null
-
ifPrev
public ListOperation ifPrev(ListKey key, ListKey prevKey)
Adds a condition that requires the specified
prevKey
to be right before the specifiedkey
when the operation is applied. Anull
prevKey
can be used to represent the head of the list.Parameters:
key
- the reference key, notnull
prevKey
- the required key, ornull
to represent the head of the listReturns:
this operation, not
null
-
ifFirst
public ListOperation ifFirst(ListKey key)
Adds a condition that requires the specified
key
to be the first in the list.Parameters:
key
- the key, notnull
Returns:
this operation, not
null
-
ifEmpty
public ListOperation ifEmpty()
Adds a condition that requires the list to be empty.
Returns:
this operation, not
null
-
ifNotEmpty
public ListOperation ifNotEmpty()
Adds a condition that requires the list not to be empty.
Returns:
this operation, not
null
-
ifValue
public ListOperation ifValue(ListKey key, Object value)
Add a condition that requires the specified
key
to have the specifiedvalue
.Parameters:
key
- the key, notnull
value
- the expected valueReturns:
this operation, not
null
-
-