Class ListExpression<E>
java.lang.Object
javafx.beans.binding.ListExpression<E>
- Type Parameters:
-
E- the type of theListelements.
- All Implemented Interfaces:
-
Iterable<E>,Collection<E>,List<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
| 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
| Constructor | Description |
|---|---|
ListExpression() |
Creates a default ListExpression. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
void |
add |
|
boolean |
add |
|
boolean |
addAll |
|
boolean |
addAll |
A convenience method for var-arg addition of elements. |
boolean |
addAll |
|
StringBinding |
asString() |
|
void |
clear() |
|
boolean |
contains |
|
boolean |
containsAll |
|
abstract ReadOnlyBooleanProperty |
emptyProperty() |
A boolean property that is true, if the list is empty. |
E |
get |
|
int |
getSize() |
The size of the list |
ObservableList<E> |
getValue() |
Returns the current value of this ObservableValue
|
int |
indexOf |
|
boolean |
isEmpty() |
Gets the value of the empty property. |
BooleanBinding |
isEqualTo |
|
BooleanBinding |
isNotEqualTo |
|
BooleanBinding |
isNotNull() |
|
BooleanBinding |
isNull() |
|
Iterator<E> |
iterator() |
|
int |
lastIndexOf |
|
static <E> ListExpression<E> |
listExpression |
Returns a ListExpression that wraps a ObservableListValue. |
ListIterator<E> |
listIterator() |
|
ListIterator<E> |
listIterator |
|
E |
remove |
|
void |
remove |
A simplified way of calling sublist(from, to).clear(). |
boolean |
remove |
|
boolean |
removeAll |
A convenience method for var-arg usage of the removeAll method. |
boolean |
removeAll |
|
boolean |
retainAll |
A convenience method for var-arg usage of the retainAll method. |
boolean |
retainAll |
|
E |
set |
|
boolean |
setAll |
Clears the ObservableList and adds all the elements passed as var-args. |
boolean |
setAll |
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 |
|
Object[] |
toArray() |
|
<T> T[] |
toArray |
|
ObjectBinding<E> |
valueAt |
Creates a new ObjectBinding that contains the element at the specified position. |
ObjectBinding<E> |
valueAt |
Creates a new ObjectBinding that contains the element at the specified position. |
Methods declared in class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods declared in interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods declared in interface java.util.List
equals, hashCode, replaceAll, sort, spliterator
Methods declared in interface javafx.beans.Observable
addListener, removeListener, subscribe
Methods declared in interface javafx.collections.ObservableList
addListener, filtered, removeListener, sorted, sorted
Methods declared in interface javafx.beans.value.ObservableObjectValue
get
Methods declared in interface javafx.beans.value.ObservableValue
addListener, flatMap, map, orElse, removeListener, subscribe, subscribe, when
Property Details
size
public abstract ReadOnlyIntegerProperty sizeProperty
An integer property that represents the size of the list.
- See Also:
empty
public abstract ReadOnlyBooleanProperty emptyProperty
A boolean property that is
true, if the list is empty.- See Also:
Constructor Details
ListExpression
public ListExpression()
Creates a default
ListExpression.Method Details
getValue
public ObservableList<E> getValue()
Description copied from interface:
ObservableValueReturns the current value of this
ObservableValue
- Specified by:
-
getValuein interfaceObservableValue<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 wrappedList - Parameters:
-
value- The sourceObservableListValue - Returns:
- A
ListExpressionthat wraps theObservableListValueif necessary - Throws:
-
NullPointerException- ifvalueisnull
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:
emptyProperty
public abstract ReadOnlyBooleanProperty emptyProperty()
A boolean property that is
true, if the list is empty.- Returns:
- the
ReadOnlyBooleanProperty - See Also:
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- ifindex < 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- ifindexisnull
isEqualTo
public BooleanBinding isEqualTo(ObservableList<?> other)
- Parameters:
-
other- the otherObservableList - Returns:
- the new
BooleanBinding - Throws:
-
NullPointerException- ifotherisnull
isNotEqualTo
public BooleanBinding isNotEqualTo(ObservableList<?> other)
- Parameters:
-
other- the otherObservableList - Returns:
- the new
BooleanBinding - Throws:
-
NullPointerException- ifotherisnull
isNull
public BooleanBinding isNull()
- Returns:
- the new
BooleanBinding
isNotNull
public BooleanBinding isNotNull()
- 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:
-
sizein interfaceCollection<E> - Specified by:
-
sizein interfaceList<E>
isEmpty
public boolean isEmpty()
Gets the value of the
empty property.- Specified by:
-
isEmptyin interfaceCollection<E> - Specified by:
-
isEmptyin interfaceList<E> - Property description:
- A boolean property that is
true, if the list is empty. - Returns:
- the value of the
emptyproperty - See Also:
contains
public boolean contains(Object obj)
- Specified by:
-
containsin interfaceCollection<E> - Specified by:
-
containsin interfaceList<E>
iterator
public Iterator<E> iterator()
- Specified by:
-
iteratorin interfaceCollection<E> - Specified by:
-
iteratorin interfaceIterable<E> - Specified by:
-
iteratorin interfaceList<E>
toArray
public Object[] toArray()
- Specified by:
-
toArrayin interfaceCollection<E> - Specified by:
-
toArrayin interfaceList<E>
toArray
public <T> T[] toArray(T[] array)
- Specified by:
-
toArrayin interfaceCollection<E> - Specified by:
-
toArrayin interfaceList<E>
add
public boolean add(E element)
- Specified by:
-
addin interfaceCollection<E> - Specified by:
-
addin interfaceList<E>
remove
public boolean remove(Object obj)
- Specified by:
-
removein interfaceCollection<E> - Specified by:
-
removein interfaceList<E>
containsAll
public boolean containsAll(Collection<?> objects)
- Specified by:
-
containsAllin interfaceCollection<E> - Specified by:
-
containsAllin interfaceList<E>
addAll
public boolean addAll(Collection<? extends E> elements)
- Specified by:
-
addAllin interfaceCollection<E> - Specified by:
-
addAllin interfaceList<E>
addAll
public boolean addAll(int i, Collection<? extends E> elements)
- Specified by:
-
addAllin interfaceList<E>
removeAll
public boolean removeAll(Collection<?> objects)
- Specified by:
-
removeAllin interfaceCollection<E> - Specified by:
-
removeAllin interfaceList<E>
retainAll
public boolean retainAll(Collection<?> objects)
- Specified by:
-
retainAllin interfaceCollection<E> - Specified by:
-
retainAllin interfaceList<E>
clear
public void clear()
- Specified by:
-
clearin interfaceCollection<E> - Specified by:
-
clearin interfaceList<E>
get
public E get(int i)
- Specified by:
-
getin interfaceList<E>
set
public E set(int i, E element)
- Specified by:
-
setin interfaceList<E>
add
public void add(int i, E element)
- Specified by:
-
addin interfaceList<E>
remove
public E remove(int i)
- Specified by:
-
removein interfaceList<E>
indexOf
public int indexOf(Object obj)
- Specified by:
-
indexOfin interfaceList<E>
lastIndexOf
public int lastIndexOf(Object obj)
- Specified by:
-
lastIndexOfin interfaceList<E>
listIterator
public ListIterator<E> listIterator()
- Specified by:
-
listIteratorin interfaceList<E>
listIterator
public ListIterator<E> listIterator(int i)
- Specified by:
-
listIteratorin interfaceList<E>
subList
public List<E> subList(int from, int to)
- Specified by:
-
subListin interfaceList<E>
addAll
public boolean addAll(E... elements)
Description copied from interface:
ObservableListA convenience method for var-arg addition of elements.
- Specified by:
-
addAllin interfaceObservableList<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:
ObservableListClears the ObservableList and adds all the elements passed as var-args.
- Specified by:
-
setAllin interfaceObservableList<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:
ObservableListClears the ObservableList and adds all elements from the collection.
- Specified by:
-
setAllin interfaceObservableList<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:
ObservableListA convenience method for var-arg usage of the
removeAll method.- Specified by:
-
removeAllin interfaceObservableList<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:
ObservableListA convenience method for var-arg usage of the
retainAll method.- Specified by:
-
retainAllin interfaceObservableList<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:
ObservableListA simplified way of calling
sublist(from, to).clear(). As this is a common operation, ObservableList has this method for convenient usage.- Specified by:
-
removein interfaceObservableList<E> - Parameters:
-
from- the start of the range to remove (inclusive) -
to- the end of the range to remove (exclusive)
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.