Module javafx.base
Package javafx.beans.binding

# Class ListExpression<E>

java.lang.Object
javafx.beans.binding.ListExpression<E>

Type Parameters:
  `E` - the type of the `List` elements.

All Implemented Interfaces:
  `Iterable<E>`, `Collection<E>`, `List<E>`, `SequencedCollection<E>`, `Observable`, `ObservableListValue<E>`, `ObservableObjectValue<ObservableList<E>>`, `ObservableValue<ObservableList<E>>`, `ObservableList<E>`

Direct Known Subclasses:
  `ListBinding`, `ReadOnlyListProperty`

public abstract class ListExpression<E> extends Object implements ObservableListValue<E>
`ListExpression` is an `ObservableListValue` plus additional convenience methods to generate bindings in a fluent style.

A concrete sub-class of `ListExpression` has to implement the method `ObservableObjectValue.get()`, which provides the actual value of this expression.

If the wrapped list of a `ListExpression` is `null`, all methods implementing the `List` interface will behave as if they were applied to an immutable empty list.

Since:
  JavaFX 2.1

## Property Summary

Properties
Type
Property
Description
`abstract ReadOnlyBooleanProperty`
`empty`
A boolean property that is `true`, if the list is empty.
`abstract ReadOnlyIntegerProperty`
`size`
An integer property that represents the size of the list.

## Constructor Summary

Constructors
Constructor
Description
`ListExpression()`

## Method Summary

Modifier and Type
Method
Description
`void`
`add(int i, E element)`
`boolean`
`add(E element)`
`boolean`
`addAll(int i, Collection<? extends E> elements)`
`boolean`
`addAll(E... elements)`
A convenience method for var-arg addition of elements.
`boolean`
`addAll(Collection<? extends E> elements)`
`StringBinding`
`asString()`
Creates a `StringBinding` that holds the value of the `ListExpression` turned into a `String`.
`void`
`clear()`
`boolean`
`contains(Object obj)`
`boolean`
`containsAll(Collection<?> objects)`
`abstract ReadOnlyBooleanProperty`
`emptyProperty()`
A boolean property that is `true`, if the list is empty.
`E`
`get(int i)`
`int`
`getSize()`
The size of the list
`ObservableList<E>`
`getValue()`
Returns the current value of this `ObservableValue`
`int`
`indexOf(Object obj)`
`boolean`
`isEmpty()`
Gets the value of the `empty` property.
`BooleanBinding`
`isEqualTo(ObservableList<?> other)`
Creates a new `BooleanBinding` that holds `true` if this list is equal to another `ObservableList`.
`BooleanBinding`
`isNotEqualTo(ObservableList<?> other)`
Creates a new `BooleanBinding` that holds `true` if this list is not equal to another `ObservableList`.
`BooleanBinding`
`isNotNull()`
Creates a new `BooleanBinding` that holds `true` if the wrapped list is not `null`.
`BooleanBinding`
`isNull()`
Creates a new `BooleanBinding` that holds `true` if the wrapped list is `null`.
`Iterator<E>`
`iterator()`
`int`
`lastIndexOf(Object obj)`
`static <E> ListExpression<E>`
`listExpression(ObservableListValue<E> value)`
Returns a `ListExpression` that wraps a `ObservableListValue`.
`ListIterator<E>`
`listIterator()`
`ListIterator<E>`
`listIterator(int i)`
`E`
`remove(int i)`
`void`
`remove(int from, int to)`
A simplified way of calling `sublist(from, to).clear()`.
`boolean`
`remove(Object obj)`
`boolean`
`removeAll(E... elements)`
A convenience method for var-arg usage of the `removeAll` method.
`boolean`
`removeAll(Collection<?> objects)`
`boolean`
`retainAll(E... elements)`
A convenience method for var-arg usage of the `retainAll` method.
`boolean`
`retainAll(Collection<?> objects)`
`E`
`set(int i, E element)`
`boolean`
`setAll(E... elements)`
Clears the ObservableList and adds all the elements passed as var-args.
`boolean`
`setAll(Collection<? extends E> elements)`
Clears the ObservableList and adds all elements from the collection.
`int`
`size()`
`abstract ReadOnlyIntegerProperty`
`sizeProperty()`
An integer property that represents the size of the list.
`List<E>`
`subList(int from, int to)`
`Object[]`
`toArray()`
`<T> T[]`
`toArray(T[] array)`
`ObjectBinding<E>`
`valueAt(int index)`
Creates a new `ObjectBinding` that contains the element at the specified position.
`ObjectBinding<E>`
`valueAt(ObservableIntegerValue index)`
Creates a new `ObjectBinding` that contains the element at the specified position.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.util.Collection

`parallelStream, removeIf, stream, toArray`

### Methods inherited from interface java.lang.Iterable

`forEach`

### Methods inherited from interface java.util.List

`addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, sort, spliterator`

### Methods inherited from interface javafx.beans.Observable

`addListener, removeListener`

### Methods inherited from interface javafx.collections.ObservableList

`addListener, filtered, removeListener, sorted, sorted`

### Methods inherited from interface javafx.beans.value.ObservableObjectValue

`get`

### Methods inherited from interface javafx.beans.value.ObservableValue

`addListener, removeListener`

## Property Details

### size

public abstract ReadOnlyIntegerProperty sizeProperty
An integer property that represents the size of the list.

See Also:
  - `getSize()`
  - `sizeProperty()`

### empty

public abstract ReadOnlyBooleanProperty emptyProperty
A boolean property that is `true`, if the list is empty.

See Also:
  - `isEmpty()`
  - `emptyProperty()`

## Constructor Details

### ListExpression

public ListExpression()

## Method Details

### getValue

public ObservableList<E> getValue()
Description copied from interface: `ObservableValue`
Returns the current value of this `ObservableValue`

Specified by:
  `getValue` in interface `ObservableValue<E>`
Returns:
  The current value

### listExpression

public static <E> ListExpression<E> listExpression(ObservableListValue<E> value)
Returns a `ListExpression` that wraps a `ObservableListValue`. If the `ObservableListValue` is already a `ListExpression`, it will be returned. Otherwise a new `ListBinding` is created that is bound to the `ObservableListValue`.

Type Parameters:
  `E` - the type of the wrapped `List`
Parameters:
  `value` - The source `ObservableListValue`
Returns:
  A `ListExpression` that wraps the `ObservableListValue` if necessary
Throws:
  `NullPointerException` - if `value` is `null`

### getSize

public int getSize()
The size of the list

Returns:
  the size

### sizeProperty

public abstract ReadOnlyIntegerProperty sizeProperty()
An integer property that represents the size of the list.

Returns:
  the property
See Also:
  - `getSize()`

### emptyProperty

public abstract ReadOnlyBooleanProperty emptyProperty()
A boolean property that is `true`, if the list is empty.

Returns:
  the `ReadOnlyBooleanProperty`
See Also:
  - `isEmpty()`

### valueAt

public ObjectBinding<E> valueAt(int index)
Creates a new `ObjectBinding` that contains the element at the specified position. If `index` points behind the list, the `ObjectBinding` contains `null`.

Parameters:
  `index` - the index of the element
Returns:
  the `ObjectBinding`
Throws:
  `IllegalArgumentException` - if `index < 0`

### valueAt

public ObjectBinding<E> valueAt(ObservableIntegerValue index)
Creates a new `ObjectBinding` that contains the element at the specified position. If `index` points outside of the list, the `ObjectBinding` contains `null`.

Parameters:
  `index` - the index of the element
Returns:
  the `ObjectBinding`
Throws:
  `NullPointerException` - if `index` is `null`

### isEqualTo

public BooleanBinding isEqualTo(ObservableList<?> other)
Creates a new `BooleanBinding` that holds `true` if this list is equal to another `ObservableList`.

Parameters:
  `other` - the other `ObservableList`
Returns:
  the new `BooleanBinding`
Throws:
  `NullPointerException` - if `other` is `null`

### isNotEqualTo

public BooleanBinding isNotEqualTo(ObservableList<?> other)
Creates a new `BooleanBinding` that holds `true` if this list is not equal to another `ObservableList`.

Parameters:
  `other` - the other `ObservableList`
Returns:
  the new `BooleanBinding`
Throws:
  `NullPointerException` - if `other` is `null`

### isNull

public BooleanBinding isNull()
Creates a new `BooleanBinding` that holds `true` if the wrapped list is `null`.

Returns:
  the new `BooleanBinding`

### isNotNull

public BooleanBinding isNotNull()
Creates a new `BooleanBinding` that holds `true` if the wrapped list is not `null`.

Returns:
  the new `BooleanBinding`

### asString

public StringBinding asString()
Creates a `StringBinding` that holds the value of the `ListExpression` turned into a `String`. If the value of this `ListExpression` changes, the value of the `StringBinding` will be updated automatically.

Returns:
  the new `StringBinding`

### size

public int size()

Specified by:
  `size` in interface `Collection<E>`
Specified by:
  `size` in interface `List<E>`

### isEmpty

public boolean isEmpty()
Gets the value of the `empty` property.

Specified by:
  `isEmpty` in interface `Collection<E>`
Specified by:
  `isEmpty` in interface `List<E>`
Property description:
  A boolean property that is `true`, if the list is empty.
Returns:
  the value of the `empty` property
See Also:
  - `emptyProperty()`

### contains

public boolean contains(Object obj)

Specified by:
  `contains` in interface `Collection<E>`
Specified by:
  `contains` in interface `List<E>`

### iterator

public Iterator<E> iterator()

Specified by:
  `iterator` in interface `Collection<E>`
Specified by:
  `iterator` in interface `Iterable<E>`
Specified by:
  `iterator` in interface `List<E>`

### toArray

public Object[] toArray()

Specified by:
  `toArray` in interface `Collection<E>`
Specified by:
  `toArray` in interface `List<E>`

### toArray

public <T> T[] toArray(T[] array)

Specified by:
  `toArray` in interface `Collection<E>`
Specified by:
  `toArray` in interface `List<E>`

### add

public boolean add(E element)

Specified by:
  `add` in interface `Collection<E>`
Specified by:
  `add` in interface `List<E>`

### remove

public boolean remove(Object obj)

Specified by:
  `remove` in interface `Collection<E>`
Specified by:
  `remove` in interface `List<E>`

### containsAll

public boolean containsAll(Collection<?> objects)

Specified by:
  `containsAll` in interface `Collection<E>`
Specified by:
  `containsAll` in interface `List<E>`

### addAll

public boolean addAll(Collection<? extends E> elements)

Specified by:
  `addAll` in interface `Collection<E>`
Specified by:
  `addAll` in interface `List<E>`

### addAll

public boolean addAll(int i, Collection<? extends E> elements)

Specified by:
  `addAll` in interface `List<E>`

### removeAll

public boolean removeAll(Collection<?> objects)

Specified by:
  `removeAll` in interface `Collection<E>`
Specified by:
  `removeAll` in interface `List<E>`

### retainAll

public boolean retainAll(Collection<?> objects)

Specified by:
  `retainAll` in interface `Collection<E>`
Specified by:
  `retainAll` in interface `List<E>`

### clear

public void clear()

Specified by:
  `clear` in interface `Collection<E>`
Specified by:
  `clear` in interface `List<E>`

### get

public E get(int i)

Specified by:
  `get` in interface `List<E>`

### set

public E set(int i, E element)

Specified by:
  `set` in interface `List<E>`

### add

public void add(int i, E element)

Specified by:
  `add` in interface `List<E>`

### remove

public E remove(int i)

Specified by:
  `remove` in interface `List<E>`

### indexOf

public int indexOf(Object obj)

Specified by:
  `indexOf` in interface `List<E>`

### lastIndexOf

public int lastIndexOf(Object obj)

Specified by:
  `lastIndexOf` in interface `List<E>`

### listIterator

public ListIterator<E> listIterator()

Specified by:
  `listIterator` in interface `List<E>`

### listIterator

public ListIterator<E> listIterator(int i)

Specified by:
  `listIterator` in interface `List<E>`

### subList

public List<E> subList(int from, int to)

Specified by:
  `subList` in interface `List<E>`

### addAll

public boolean addAll(E... elements)
Description copied from interface: `ObservableList`
A convenience method for var-arg addition of elements.

Specified by:
  `addAll` in interface `ObservableList<E>`
Parameters:
  `elements` - the elements to add
Returns:
  true (as specified by Collection.add(E))

### setAll

public boolean setAll(E... elements)
Description copied from interface: `ObservableList`
Clears the ObservableList and adds all the elements passed as var-args.

Specified by:
  `setAll` in interface `ObservableList<E>`
Parameters:
  `elements` - the elements to set
Returns:
  true (as specified by Collection.add(E))

### setAll

public boolean setAll(Collection<? extends E> elements)
Description copied from interface: `ObservableList`
Clears the ObservableList and adds all elements from the collection.

Specified by:
  `setAll` in interface `ObservableList<E>`
Parameters:
  `elements` - the collection with elements that will be added to this observableArrayList
Returns:
  true (as specified by Collection.add(E))

### removeAll

public boolean removeAll(E... elements)
Description copied from interface: `ObservableList`
A convenience method for var-arg usage of the `removeAll` method.

Specified by:
  `removeAll` in interface `ObservableList<E>`
Parameters:
  `elements` - the elements to be removed
Returns:
  true if list changed as a result of this call

### retainAll

public boolean retainAll(E... elements)
Description copied from interface: `ObservableList`
A convenience method for var-arg usage of the `retainAll` method.

Specified by:
  `retainAll` in interface `ObservableList<E>`
Parameters:
  `elements` - the elements to be retained
Returns:
  true if list changed as a result of this call

### remove

public void remove(int from, int to)
Description copied from interface: `ObservableList`
A simplified way of calling `sublist(from, to).clear()`. As this is a common operation, ObservableList has this method for convenient usage.

Specified by:
  `remove` in interface `ObservableList<E>`
Parameters:
  `from` - the start of the range to remove (inclusive)
  `to` - the end of the range to remove (exclusive)