Class SharedListSignal<T extends @Nullable Object>
- Type Parameters:
T- the element type
- All Implemented Interfaces:
Signal<@NonNull List<SharedValueSignal<T>>>,Serializable
SharedValueSignal instance which enables atomic updates to the value
of that list entry.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA list insertion position before and/or after the referenced entries.Nested classes/interfaces inherited from class com.vaadin.flow.signals.shared.AbstractSignal
AbstractSignal.ChildSignalFactory<I extends AbstractSignal<?>>, AbstractSignal.ResultConverter<T extends @Nullable Object> -
Field Summary
Fields inherited from class com.vaadin.flow.signals.shared.AbstractSignal
ANYTHING_GOES -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSharedListSignal(SignalTree tree, Id id, CommandValidator 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.SharedListSignal(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.booleanprotected List<SharedValueSignal<T>> extractValue(@Nullable Node.Data data) Extracts the value for this signal from the given signal data node.get()Gets the current value of this signal.inthashCode()insertAt(T value, SharedListSignal.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(AbstractSignal<T> child, SharedListSignal.ListPosition to) Moves the given child signal to the given position in this list.peek()Reads the value without setting up any dependencies.Reads the confirmed value without setting up any dependencies.remove(SharedValueSignal<T> child) Removes the given child from this list.toString()protected ObjectusageChangeValue(Node.Data data) Gets a reference value that will be used to determine whether a dependency based on previous usage should be invalidated.verifyChild(AbstractSignal<?> child) Checks that the given signal is a child in this list.verifyPosition(AbstractSignal<?> child, SharedListSignal.ListPosition expectedPosition) Checks that the given child is at the given position in this list.withValidator(CommandValidator validator) Wraps this signal with a validator.Methods inherited from class com.vaadin.flow.signals.shared.AbstractSignal
createUsage, data, data, fromJson, id, mergeValidators, nodeValue, remove, submit, submit, submit, submitInsert, submitVoidOperation, toJson, tree, validator
-
Constructor Details
-
SharedListSignal
Creates a new list signal with the given element type. The signal does not support clustering.- Parameters:
elementType- the element type, notnull
-
-
Method Details
-
get
Description copied from interface:SignalGets the current value of this signal. The value is read in a way that takes the current transaction into account and in the case of clustering also changes that have been submitted to the cluster but not yet confirmed.If the signal implementation supports transactions, then reading the value in a regular (i.e.
Transaction.Type.STAGED) transaction makes the transaction depend on the value so that the transaction fails in case the signal value is changed concurrently.Reading the value inside an
Signal.unboundEffect(EffectAction)orSignal.computed(SignalComputation)callback sets up that effect or computed signal to depend on the signal.This method must only be called within a reactive context such as an effect, a computed signal, an explicit
Signal.untracked(ValueSupplier)block, or atransaction. Calling it outside such a context throws anIllegalStateException. UseSignal.peek()for one-time reads that do not need dependency tracking.- Specified by:
getin interfaceSignal<T extends @Nullable Object>- Overrides:
getin classAbstractSignal<@NonNull List<SharedValueSignal<T extends @Nullable Object>>>- Returns:
- the signal value
-
peek
Description copied from interface:SignalReads the value without setting up any dependencies. This method returns the same value asSignal.get()but without creating a dependency when used inside a transaction, effect or computed signal.Unlike
Signal.get(), this method can be called outside a reactive context and is the recommended way to read a signal value for one-time use, such as logging, assertions, or initializing non-reactive UI.- Specified by:
peekin interfaceSignal<T extends @Nullable Object>- Overrides:
peekin classAbstractSignal<@NonNull List<SharedValueSignal<T extends @Nullable Object>>>- Returns:
- the signal value
-
peekConfirmed
Description copied from class:AbstractSignalReads the confirmed value without setting up any dependencies. The confirmed value doesn't consider changes in the current transaction or changes that have been submitted but not yet confirmed in a cluster.- Overrides:
peekConfirmedin classAbstractSignal<@NonNull List<SharedValueSignal<T extends @Nullable Object>>>- Returns:
- the confirmed signal value
-
extractValue
Description copied from class:AbstractSignalExtracts the value for this signal from the given signal data node.- Specified by:
extractValuein classAbstractSignal<@NonNull List<SharedValueSignal<T extends @Nullable Object>>>- Parameters:
data- the data node to extract the value from, ornullif the node doesn't exist in the tree- Returns:
- the signal value
-
usageChangeValue
Description copied from class:AbstractSignalGets 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
AbstractSignal.get()of this signal changes.- Specified by:
usageChangeValuein classAbstractSignal<@NonNull List<SharedValueSignal<T extends @Nullable Object>>>- 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 insert- Returns:
- 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 insert- Returns:
- an operation containing a signal for the inserted entry and the eventual result
-
clear
Removes all children from this list. Note that is this list shares data with aSharedNodeSignalthat has map children, then the map children will also be removed.- Overrides:
clearin classAbstractSignal<@NonNull List<SharedValueSignal<T extends @Nullable Object>>>- 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 byasNode(), 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:AbstractSignalConverts this signal into a node signal. This allows further conversion into any specific signal type through the methods inSharedNodeSignal. The converted signal is backed by the same underlying data and uses the same validator as this signal.- Overrides:
asNodein classAbstractSignal<@NonNull List<SharedValueSignal<T extends @Nullable Object>>>- Returns:
- this signal as a node signal, not
null
-
equals
-
hashCode
public int hashCode() -
toString
-