public class CollectionUtils
extends java.lang.Object
CollectionUtils
contains a method to compute the old value of an
ObservableList
for a given
ListChangeListener.Change
event. For details, see
getPreviousContents(javafx.collections.ListChangeListener.Change)
.Constructor and Description |
---|
CollectionUtils() |
Modifier and Type | Method and Description |
---|---|
static <E> ObservableMultiset<E> |
emptyMultiset()
Returns an empty, unmodifiable
ObservableMultiset . |
static <K,V> ObservableSetMultimap<K,V> |
emptySetMultimap()
Returns an empty, unmodifiable
ObservableSetMultimap . |
static <E> int[] |
getPermutation(javafx.collections.ListChangeListener.Change<? extends E> change)
Computes the permutation for the given
ListChangeListener.Change . |
static <E> java.util.List<E> |
getPreviousContents(javafx.collections.ListChangeListener.Change<E> change)
Computes the previous contents of the source
ObservableList
before the given ListChangeListener.Change was
applied. |
static <E> javafx.collections.ObservableList<E> |
observableArrayList()
Returns a (modifiable) new
ObservableList wrapping an
ArrayList . |
static <E> javafx.collections.ObservableList<E> |
observableArrayList(java.util.Collection<? extends E> collection)
Create a new
ObservableList that is backed by an
ArrayList that contains the contents of the given
Collection . |
static <E> javafx.collections.ObservableList<E> |
observableArrayList(E... elements)
Creates a new
ObservableList that contains the given elements. |
static <K,V> ObservableSetMultimap<K,V> |
observableHashMultimap()
Returns a (modifiable) new
ObservableSetMultimap wrapping a
HashMultimap . |
static <E> ObservableMultiset<E> |
observableHashMultiset()
Returns a (modifiable) new
ObservableMultiset wrapping a
HashMultiset . |
static <E> javafx.collections.ObservableList<E> |
observableList(java.util.List<E> list)
Returns a (modifiable) new
ObservableList wrapping the given
List . |
static <E> ObservableMultiset<E> |
observableMultiset(com.google.common.collect.Multiset<E> multiset)
Returns a (modifiable) new
ObservableMultiset wrapping the given
List . |
static <K,V> ObservableSetMultimap<K,V> |
observableSetMultimap(com.google.common.collect.SetMultimap<K,V> setMultimap)
Returns a (modifiable) new
ObservableSetMultimap wrapping the
given SetMultimap . |
static <E extends java.lang.Comparable<? super E>> |
sort(javafx.collections.ObservableList<E> observableList)
Sorts the given
ObservableList using the default
Comparator . |
static <E> void |
sort(javafx.collections.ObservableList<E> observableList,
java.util.Comparator<? super E> comparator)
Sorts the given
ObservableList using the given Comparator
. |
static <E> ObservableMultiset<E> |
unmodifiableObservableMultiset(ObservableMultiset<E> multiset)
Returns an unmodifiable
ObservableMultiset wrapping the given
ObservableMultiset . |
static <K,V> ObservableSetMultimap<K,V> |
unmodifiableObservableSetMultimap(ObservableSetMultimap<K,V> setMultimap)
Returns an unmodifiable
ObservableSetMultimap wrapping the given
ObservableSetMultimap . |
public static <E> ObservableMultiset<E> emptyMultiset()
ObservableMultiset
.E
- The element type of the ObservableMultiset
.ObservableMultiset
.public static <K,V> ObservableSetMultimap<K,V> emptySetMultimap()
ObservableSetMultimap
.K
- The key type of the ObservableSetMultimap
.V
- The value type of the ObservableSetMultimap
.ObservableSetMultimap
.public static <E> int[] getPermutation(javafx.collections.ListChangeListener.Change<? extends E> change)
ListChangeListener.Change
.E
- The element type of the ObservableList
that was
changed.change
- The change, for which ListChangeListener.Change.wasPermutated()
has to
return true
.public static <E> java.util.List<E> getPreviousContents(javafx.collections.ListChangeListener.Change<E> change)
ObservableList
before the given ListChangeListener.Change
was
applied.E
- The element type of the ObservableList
.change
- The ListChangeListener.Change
for
which to compute the previous contents.List
that resembles the state of the
source ObservableList
before the change.public static <E> javafx.collections.ObservableList<E> observableArrayList()
ObservableList
wrapping an
ArrayList
.
Please note that in order to obtain proper change notifications when
sorting the returned ObservableList
,
sort(ObservableList)
or
sort(ObservableList, Comparator)
have to be used instead of
FXCollections.sort(ObservableList)
and
FXCollections.sort(ObservableList, Comparator)
.E
- The element type of the ObservableList
. The
List
to wrap.ObservableList
wrapping the given List
.public static <E> javafx.collections.ObservableList<E> observableArrayList(java.util.Collection<? extends E> collection)
ObservableList
that is backed by an
ArrayList
that contains the contents of the given
Collection
.E
- The element type of the ObservableList
.collection
- The Collection
that provides the initial contents of
the to be created ObservableList
.ObservableList
containing the given contents.public static <E> javafx.collections.ObservableList<E> observableArrayList(E... elements)
ObservableList
that contains the given elements.E
- The element type of the ObservableList
.elements
- The elements that will be added to the returned
ObservableList
public static <K,V> ObservableSetMultimap<K,V> observableHashMultimap()
ObservableSetMultimap
wrapping a
HashMultimap
.K
- The key type of the ObservableSetMultimap
.V
- The value type of the ObservableSetMultimap
ObservableSetMultimap
wrapping a HashMultimap
.public static <E> ObservableMultiset<E> observableHashMultiset()
ObservableMultiset
wrapping a
HashMultiset
.E
- The element type of the ObservableList
.ObservableMultiset
wrapping a HashMultiset
.public static <E> javafx.collections.ObservableList<E> observableList(java.util.List<E> list)
ObservableList
wrapping the given
List
.
Please note that in order to obtain proper change notifications when
sorting the returned ObservableList
,
sort(ObservableList)
or
sort(ObservableList, Comparator)
have to be used instead of
FXCollections.sort(ObservableList)
and
FXCollections.sort(ObservableList, Comparator)
.E
- The element type of the ObservableList
.list
- The List
to wrap.ObservableList
wrapping the given List
.public static <E> ObservableMultiset<E> observableMultiset(com.google.common.collect.Multiset<E> multiset)
ObservableMultiset
wrapping the given
List
.E
- The element type of the ObservableList
.multiset
- The Multiset
to wrap.ObservableMultiset
wrapping the given List
.public static <K,V> ObservableSetMultimap<K,V> observableSetMultimap(com.google.common.collect.SetMultimap<K,V> setMultimap)
ObservableSetMultimap
wrapping the
given SetMultimap
.K
- The key type of the ObservableSetMultimap
.V
- The value type of the ObservableSetMultimap
setMultimap
- The SetMultimap
to wrap.ObservableSetMultimap
wrapping the given List
.public static <E extends java.lang.Comparable<? super E>> void sort(javafx.collections.ObservableList<E> observableList)
ObservableList
using the default
Comparator
.E
- The value type of the ObservableList
.observableList
- The ObservableList
to sort.public static <E> void sort(javafx.collections.ObservableList<E> observableList, java.util.Comparator<? super E> comparator)
ObservableList
using the given Comparator
.E
- The value type of the ObservableList
.observableList
- The ObservableList
to sort.comparator
- The Comparator
to use.public static <E> ObservableMultiset<E> unmodifiableObservableMultiset(ObservableMultiset<E> multiset)
ObservableMultiset
wrapping the given
ObservableMultiset
.E
- The element type of the ObservableMultiset
.multiset
- The ObservableMultiset
to wrap.ObservableMultiset
.public static <K,V> ObservableSetMultimap<K,V> unmodifiableObservableSetMultimap(ObservableSetMultimap<K,V> setMultimap)
ObservableSetMultimap
wrapping the given
ObservableSetMultimap
.K
- The key type of the ObservableSetMultimap
.V
- The value type of the ObservableSetMultimap
.setMultimap
- The ObservableSetMultimap
to wrap.ObservableSetMultimap
.Copyright (c) 2014 itemis AG and others. All rights reserved.