ListSignal
class ListSignal<E>
Extends: Signal<List<E>>
Package: dev.joid.lib.signal.impl.iterable · Module: core · Source: ListSignal.java
Signal of a list, changed through its own methods so that every change notifies the nodes and listeners that follow it.
Description
Section titled “Description”The value is a read-only copy: get() returns a list that throws UnsupportedOperationException on any change.
Each method of the signal copies the list, applies the change to the copy and writes it; called from another thread, the change applies on the render thread to the list held then.
The read methods (get(int), size(), contains(...)…) record the read like Signal.get.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
| ListSignal() | Creates a signal whose value and default value are an empty list. | |
| ListSignal(Collection | Creates a signal whose value and default value are a copy of value, in its iteration order. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
this | clear() fluent | Removes every element, then returns this signal. |
this | add(E e) fluent | Adds e at the end of the list, then returns this signal. |
this | remove(E e) fluent | Removes the first element equal to e, then returns this signal; nothing changes when there is none. |
this | remove(int index) fluent | Removes the element at index, then returns this signal. |
E | get(int index) | Returns the element at index; throws an IndexOutOfBoundsException when there is none. |
this | set(int index, E element) fluent | Replaces the element at index with element, then returns this signal. |
boolean | contains(E e) | If true, the list holds an element equal to e. |
int | indexOf(E e) | Returns the index of the first element equal to e, or -1. |
boolean | isEmpty() | If true, the list holds no element. |
int | size() | Returns the number of elements. |
For subclasses
Section titled “For subclasses”| Returns | Signature | Summary |
|---|---|---|
List<E> | seal(List | Returns a read-only copy of value, which the signal stores. |
Inherited from Signal (10)
batch · silent · peek · isPresent · isWritable · toString · from · reset · removeOnChange · map
Events
Section titled “Events”Creation details
Section titled “Creation details”ListSignal
Section titled “ListSignal”ListSignal()
Creates a signal whose value and default value are an empty list.
ListSignal(Collection<E> value)
Creates a signal whose value and default value are a copy of value, in its iteration order.
Method details
Section titled “Method details”this clear() fluent
Removes every element, then returns this signal.
this add(E e) fluent
Adds e at the end of the list, then returns this signal.
remove
Section titled “remove”this remove(E e) fluent
Removes the first element equal to e, then returns this signal; nothing changes when there is none.
this remove(int index) fluent
Removes the element at index, then returns this signal.
An index outside the list throws an IndexOutOfBoundsException when the change applies.
E get(int index)
Returns the element at index; throws an IndexOutOfBoundsException when there is none.
this set(int index, E element) fluent
Replaces the element at index with element, then returns this signal.
An index outside the list throws an IndexOutOfBoundsException when the change applies.
contains
Section titled “contains”boolean contains(E e)
If true, the list holds an element equal to e.
indexOf
Section titled “indexOf”int indexOf(E e)
Returns the index of the first element equal to e, or -1.
isEmpty
Section titled “isEmpty”boolean isEmpty()
If true, the list holds no element.
int size()
Returns the number of elements.
List<E> seal(List<E> value) hook protected
Returns a read-only copy of value, which the signal stores.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
