Class CollectionUtils
java.lang.Object
org.eclipse.gef.common.collections.CollectionUtils
The
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <E> ObservableMultiset<E>Returns an empty, unmodifiableObservableMultiset.static <K,V> ObservableSetMultimap<K, V> Returns an empty, unmodifiableObservableSetMultimap.static <E> int[]getPermutation(javafx.collections.ListChangeListener.Change<? extends E> change) Computes the permutation for the givenListChangeListener.Change.static <E> List<E>getPreviousContents(javafx.collections.ListChangeListener.Change<E> change) Computes the previous contents of the sourceObservableListbefore the givenListChangeListener.Changewas applied.static <E> javafx.collections.ObservableList<E>Returns a (modifiable) newObservableListwrapping anArrayList.static <E> javafx.collections.ObservableList<E>observableArrayList(E... elements) Creates a newObservableListthat contains the given elements.static <E> javafx.collections.ObservableList<E>observableArrayList(Collection<? extends E> collection) Create a newObservableListthat is backed by anArrayListthat contains the contents of the givenCollection.static <K,V> ObservableSetMultimap<K, V> Returns a (modifiable) newObservableSetMultimapwrapping aHashMultimap.static <E> ObservableMultiset<E>Returns a (modifiable) newObservableMultisetwrapping aHashMultiset.static <E> javafx.collections.ObservableList<E>observableList(List<E> list) Returns a (modifiable) newObservableListwrapping the givenList.static <E> ObservableMultiset<E>observableMultiset(Multiset<E> multiset) Returns a (modifiable) newObservableMultisetwrapping the givenList.static <K,V> ObservableSetMultimap<K, V> observableSetMultimap(SetMultimap<K, V> setMultimap) Returns a (modifiable) newObservableSetMultimapwrapping the givenSetMultimap.static <E extends Comparable<? super E>>
voidsort(javafx.collections.ObservableList<E> observableList) Sorts the givenObservableListusing the defaultComparator.static <E> voidsort(javafx.collections.ObservableList<E> observableList, Comparator<? super E> comparator) Sorts the givenObservableListusing the givenComparator.static <E> ObservableMultiset<E>unmodifiableObservableMultiset(ObservableMultiset<E> multiset) Returns an unmodifiableObservableMultisetwrapping the givenObservableMultiset.static <K,V> ObservableSetMultimap<K, V> unmodifiableObservableSetMultimap(ObservableSetMultimap<K, V> setMultimap) Returns an unmodifiableObservableSetMultimapwrapping the givenObservableSetMultimap.
-
Constructor Details
-
CollectionUtils
public CollectionUtils()
-
-
Method Details
-
emptyMultiset
Returns an empty, unmodifiableObservableMultiset.- Type Parameters:
E- The element type of theObservableMultiset.- Returns:
- An empty, unmodifiable
ObservableMultiset.
-
emptySetMultimap
Returns an empty, unmodifiableObservableSetMultimap.- Type Parameters:
K- The key type of theObservableSetMultimap.V- The value type of theObservableSetMultimap.- Returns:
- An empty, unmodifiable
ObservableSetMultimap.
-
getPermutation
public static <E> int[] getPermutation(javafx.collections.ListChangeListener.Change<? extends E> change) Computes the permutation for the givenListChangeListener.Change.- Type Parameters:
E- The element type of theObservableListthat was changed.- Parameters:
change- The change, for whichListChangeListener.Change.wasPermutated()has to returntrue.- Returns:
- An integer array mapping previous indexes to current ones.
-
getPreviousContents
public static <E> List<E> getPreviousContents(javafx.collections.ListChangeListener.Change<E> change) Computes the previous contents of the sourceObservableListbefore the givenListChangeListener.Changewas applied.- Type Parameters:
E- The element type of theObservableList.- Parameters:
change- TheListChangeListener.Changefor which to compute the previous contents.- Returns:
- A newly created
Listthat resembles the state of the sourceObservableListbefore the change.
-
observableArrayList
public static <E> javafx.collections.ObservableList<E> observableArrayList()Returns a (modifiable) newObservableListwrapping anArrayList. Please note that in order to obtain proper change notifications when sorting the returnedObservableList,sort(ObservableList)orsort(ObservableList, Comparator)have to be used instead ofFXCollections.sort(ObservableList)andFXCollections.sort(ObservableList, Comparator). -
observableArrayList
public static <E> javafx.collections.ObservableList<E> observableArrayList(Collection<? extends E> collection) Create a newObservableListthat is backed by anArrayListthat contains the contents of the givenCollection.- Type Parameters:
E- The element type of theObservableList.- Parameters:
collection- TheCollectionthat provides the initial contents of the to be createdObservableList.- Returns:
- A new
ObservableListcontaining the given contents.
-
observableArrayList
public static <E> javafx.collections.ObservableList<E> observableArrayList(E... elements) Creates a newObservableListthat contains the given elements.- Type Parameters:
E- The element type of theObservableList.- Parameters:
elements- The elements that will be added to the returnedObservableList- Returns:
- a newly created observableArrayList
-
observableHashMultimap
Returns a (modifiable) newObservableSetMultimapwrapping aHashMultimap.- Type Parameters:
K- The key type of theObservableSetMultimap.V- The value type of theObservableSetMultimap- Returns:
- An
ObservableSetMultimapwrapping aHashMultimap.
-
observableHashMultiset
Returns a (modifiable) newObservableMultisetwrapping aHashMultiset.- Type Parameters:
E- The element type of theObservableList.- Returns:
- An
ObservableMultisetwrapping aHashMultiset.
-
observableList
Returns a (modifiable) newObservableListwrapping the givenList. Please note that in order to obtain proper change notifications when sorting the returnedObservableList,sort(ObservableList)orsort(ObservableList, Comparator)have to be used instead ofFXCollections.sort(ObservableList)andFXCollections.sort(ObservableList, Comparator). -
observableMultiset
Returns a (modifiable) newObservableMultisetwrapping the givenList.- Type Parameters:
E- The element type of theObservableList.- Parameters:
multiset- TheMultisetto wrap.- Returns:
- An
ObservableMultisetwrapping the givenList.
-
observableSetMultimap
Returns a (modifiable) newObservableSetMultimapwrapping the givenSetMultimap.- Type Parameters:
K- The key type of theObservableSetMultimap.V- The value type of theObservableSetMultimap- Parameters:
setMultimap- TheSetMultimapto wrap.- Returns:
- An
ObservableSetMultimapwrapping the givenList.
-
sort
public static <E extends Comparable<? super E>> void sort(javafx.collections.ObservableList<E> observableList) Sorts the givenObservableListusing the defaultComparator.- Type Parameters:
E- The value type of theObservableList.- Parameters:
observableList- TheObservableListto sort.
-
sort
public static <E> void sort(javafx.collections.ObservableList<E> observableList, Comparator<? super E> comparator) Sorts the givenObservableListusing the givenComparator.- Type Parameters:
E- The value type of theObservableList.- Parameters:
observableList- TheObservableListto sort.comparator- TheComparatorto use.
-
unmodifiableObservableMultiset
public static <E> ObservableMultiset<E> unmodifiableObservableMultiset(ObservableMultiset<E> multiset) Returns an unmodifiableObservableMultisetwrapping the givenObservableMultiset.- Type Parameters:
E- The element type of theObservableMultiset.- Parameters:
multiset- TheObservableMultisetto wrap.- Returns:
- An unmodifiable wrapper around the given
ObservableMultiset.
-
unmodifiableObservableSetMultimap
public static <K,V> ObservableSetMultimap<K,V> unmodifiableObservableSetMultimap(ObservableSetMultimap<K, V> setMultimap) Returns an unmodifiableObservableSetMultimapwrapping the givenObservableSetMultimap.- Type Parameters:
K- The key type of theObservableSetMultimap.V- The value type of theObservableSetMultimap.- Parameters:
setMultimap- TheObservableSetMultimapto wrap.- Returns:
- An unmodifiable wrapper around the given
ObservableSetMultimap.
-