com.vaadin.signals.
Class ListSignal<T>
Type Parameters:
T
- the element type
A signal containing a list of values. Supports atomic updates to the list
structure. Each value in the list is accessed as a separate
ValueSignal
instance which enables atomic updates to the value of
that list entry.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
A list insertion position before and/or after the referenced entries.
-
Field Summary
Fields inherited from class com.vaadin.signals.Signal
ANYTHING_GOES
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ListSignal
(SignalTree tree, Id id, Predicate<SignalCommand> validator, Class<T> elementType) Creates a new list signal instance with the given id and validator for the given signal tree with the given element type.
ListSignal
(Class<T> elementType) Creates a new list signal with the given element type.
-
Method Summary
Modifier and TypeMethodDescriptionasNode()
Converts this signal into a node signal.
Wraps this signal to not accept changes.
clear()
Removes all children from this list.
boolean
protected List<ValueSignal<T>>
extractValue
(Node.Data data) Extracts the value for this signal from the given signal data node.
int
hashCode()
insertAt
(T value, ListSignal.ListPosition at) Inserts a value at the given position in this list.
insertFirst
(T value) Inserts a value as the first entry in this list.
insertLast
(T value) Inserts a value as the last entry in this list.
moveTo
(Signal<T> child, ListSignal.ListPosition to) Moves the given child signal to the given position in this list.
remove
(ValueSignal<T> child) Removes the given child from this list.
toString()
protected Object
usageChangeValue
(Node.Data data) Gets a reference value that will be used to determine whether a dependency based on previous usage should be invalidated.
verifyChild
(Signal<?> child) Checks that the given signal is a child in this list.
verifyPosition
(Signal<?> child, ListSignal.ListPosition expectedPosition) Checks that the given child is at the given position in this list.
withValidator
(Predicate<SignalCommand> validator) Wraps this signal with a validator.
Methods inherited from class com.vaadin.signals.Signal
computed, createUsage, data, data, effect, fromJson, id, map, mergeValidators, nodeValue, peek, peekConfirmed, remove, runInTransaction, runInTransaction, runWithoutTransaction, runWithoutTransaction, submit, submit, submit, submitInsert, submitVoidOperation, toJson, tree, untracked, validator, value
-
Constructor Details
-
ListSignal
Creates a new list signal with the given element type. The signal does not support clustering.
Parameters:
elementType
- the element type, notnull
-
ListSignal
protected ListSignal(SignalTree tree, Id id, Predicate<SignalCommand> validator, Class<T> elementType) Creates a new list signal instance with the given id and validator for the given signal tree with the given element type.
Parameters:
tree
- the signal tree that contains the value for this signal, notnull
id
- the id of the signal node within the signal tree, notnull
validator
- the validator to check operations submitted to this singal, notnull
elementType
- the element type, notnull
-
-
Method Details
-
extractValue
Description copied from class:
Signal
Extracts the value for this signal from the given signal data node.
Specified by:
extractValue
in classSignal<List<ValueSignal<T>>>
Parameters:
data
- the data node to extract the value from, ornull
if the node doesn't exist in the treeReturns:
the signal value
-
usageChangeValue
Description copied from class:
Signal
Gets a reference value that will be used to determine whether a dependency based on previous usage should be invalidated. This is done by getting one reference value when the dependency occurs and then comparing that to the current value to determine if the value has changed.
The implementation should return an object that changes if and only if the
Signal.value()
of this signal changes.Specified by:
usageChangeValue
in classSignal<List<ValueSignal<T>>>
Parameters:
data
- the data node to read from, notnull
Returns:
a reference value to use for validity checks, may be
null
-
insertFirst
Inserts a value as the first entry in this list.
Parameters:
value
- the value to insertReturns:
an operation containing a signal for the inserted entry and the eventual result
-
insertLast
Inserts a value as the last entry in this list.
Parameters:
value
- the value to insertReturns:
an operation containing a signal for the inserted entry and the eventual result
-
insertAt
Inserts a value at the given position in this list. The operation fails if the position is not valid at the time when the operation is processed.
Parameters:
value
- the value to insertat
- the insert position, notnull
Returns:
an operation containing a signal for the inserted entry and the eventual result
-
moveTo
Moves the given child signal to the given position in this list. The operation fails if the child is not a child or if this list of if position is not valid at the time when the operation is processed.
Parameters:
child
- the child signal to move, notnull
to
- the position to move to, notnull
Returns:
an operation containing the eventual result
-
remove
Removes the given child from this list. The operation fails if the child is not a child of this list at the time when the operation is processed.
Parameters:
child
- the child to remove, notnull
Returns:
an operation containing the eventual result
-
clear
Removes all children from this list. Note that is this list shares data with a
NodeSignal
that has map children, then the map children will also be removed.Overrides:
clear
in classSignal<List<ValueSignal<T>>>
Returns:
an operation containing the eventual result
-
verifyPosition
public SignalOperation<Void> verifyPosition(Signal<?> child, ListSignal.ListPosition expectedPosition) Checks that the given child is at the given position in this list. This operation is only meaningful to use as a condition in a
transaction
. The result of the returned operation will be resolved as successful if the given child is a child of this list and at the given position when the operation is processed.Parameters:
child
- the child to test, notnull
expectedPosition
- the expected position of the child, notnull
Returns:
an operation containing the eventual result
-
verifyChild
Checks that the given signal is a child in this list. This operation is only meaningful to use as a condition in a
transaction
. The result of the returned operation will be resolved as successful if the given child is a child of this list and at the given position when the operation is processed.Parameters:
child
- the child to look for test, notnull
Returns:
an operation containing the eventual result
-
withValidator
Wraps this signal with a validator. The validator is used to check all value changing commands issued through the new signal instance and all child signals. If this signal has a validator, then the new signal will use both validators. Note that due to the way validators are retained by
asNode()
, there's a possibility that the validator also receives commands that cannot be directly issued for a list signal or its children.This signal will keep its current configuration and changes applied through this instance will be visible through the wrapped instance.
Parameters:
validator
- the validator to use, notnull
Returns:
a new list signal that uses the validator, not
null
-
asReadonly
Wraps this signal to not accept changes. Child value signals retrieved through the wrapped signal will also not accept changes.
This signal will keep its current configuration and changes applied through this instance will be visible through the wrapped instance.
Returns:
the new readonly list signal, not
null
-
asNode
Description copied from class:
Signal
Converts this signal into a node signal. This allows further conversion into any specific signal type through the methods in
NodeSignal
. The converted signal is backed by the same underlying data and uses the same validator as this signal.Overrides:
asNode
in classSignal<List<ValueSignal<T>>>
Returns:
this signal as a node signal, not
null
-
equals
-
hashCode
public int hashCode() -
toString
-