Skip to content

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.

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.

ReturnsSignatureSummary
ListSignal()Creates a signal whose value and default value are an empty list.
ListSignal(Collection value)Creates a signal whose value and default value are a copy of value, in its iteration order.

ReturnsSignatureSummary
thisclear() fluentRemoves every element, then returns this signal.
thisadd(E e) fluentAdds e at the end of the list, then returns this signal.
thisremove(E e) fluentRemoves the first element equal to e, then returns this signal; nothing changes when there is none.
thisremove(int index) fluentRemoves the element at index, then returns this signal.
Eget(int index)Returns the element at index; throws an IndexOutOfBoundsException when there is none.
thisset(int index, E element) fluentReplaces the element at index with element, then returns this signal.
booleancontains(E e)If true, the list holds an element equal to e.
intindexOf(E e)Returns the index of the first element equal to e, or -1.
booleanisEmpty()If true, the list holds no element.
intsize()Returns the number of elements.
ReturnsSignatureSummary
List<E>seal(List value) hook protectedReturns a read-only copy of value, which the signal stores.
Inherited from Signal (10)

batch · silent · peek · isPresent · isWritable · toString · from · reset · removeOnChange · map

Inherited from Signal (1)

onChange

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.

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. 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.

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.

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

Report a problem with this page