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 SummaryConstructors
- 
Method SummaryModifier 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- 
CollectionUtilspublic CollectionUtils()
 
- 
- 
Method Details- 
emptyMultisetReturns an empty, unmodifiableObservableMultiset.- Type Parameters:
- E- The element type of the- ObservableMultiset.
- Returns:
- An empty, unmodifiable ObservableMultiset.
 
- 
emptySetMultimapReturns an empty, unmodifiableObservableSetMultimap.- Type Parameters:
- K- The key type of the- ObservableSetMultimap.
- V- The value type of the- ObservableSetMultimap.
- Returns:
- An empty, unmodifiable ObservableSetMultimap.
 
- 
getPermutationpublic 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 the- ObservableListthat was changed.
- Parameters:
- change- The change, for which- ListChangeListener.Change.wasPermutated()has to return- true.
- Returns:
- An integer array mapping previous indexes to current ones.
 
- 
getPreviousContentspublic 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 the- ObservableList.
- Parameters:
- change- The- ListChangeListener.Changefor which to compute the previous contents.
- Returns:
- A newly created Listthat resembles the state of the sourceObservableListbefore the change.
 
- 
observableArrayListpublic 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).
- 
observableArrayListpublic 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 the- ObservableList.
- Parameters:
- collection- The- Collectionthat provides the initial contents of the to be created- ObservableList.
- Returns:
- A new ObservableListcontaining the given contents.
 
- 
observableArrayListpublic static <E> javafx.collections.ObservableList<E> observableArrayList(E... elements) Creates a newObservableListthat contains the given elements.- Type Parameters:
- E- The element type of the- ObservableList.
- Parameters:
- elements- The elements that will be added to the returned- ObservableList
- Returns:
- a newly created observableArrayList
 
- 
observableHashMultimapReturns a (modifiable) newObservableSetMultimapwrapping aHashMultimap.- Type Parameters:
- K- The key type of the- ObservableSetMultimap.
- V- The value type of the- ObservableSetMultimap
- Returns:
- An ObservableSetMultimapwrapping aHashMultimap.
 
- 
observableHashMultisetReturns a (modifiable) newObservableMultisetwrapping aHashMultiset.- Type Parameters:
- E- The element type of the- ObservableList.
- Returns:
- An ObservableMultisetwrapping aHashMultiset.
 
- 
observableListReturns 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).
- 
observableMultisetReturns a (modifiable) newObservableMultisetwrapping the givenList.- Type Parameters:
- E- The element type of the- ObservableList.
- Parameters:
- multiset- The- Multisetto wrap.
- Returns:
- An ObservableMultisetwrapping the givenList.
 
- 
observableSetMultimapReturns a (modifiable) newObservableSetMultimapwrapping the givenSetMultimap.- Type Parameters:
- K- The key type of the- ObservableSetMultimap.
- V- The value type of the- ObservableSetMultimap
- Parameters:
- setMultimap- The- SetMultimapto wrap.
- Returns:
- An ObservableSetMultimapwrapping the givenList.
 
- 
sortpublic 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 the- ObservableList.
- Parameters:
- observableList- The- ObservableListto sort.
 
- 
sortpublic 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 the- ObservableList.
- Parameters:
- observableList- The- ObservableListto sort.
- comparator- The- Comparatorto use.
 
- 
unmodifiableObservableMultisetpublic static <E> ObservableMultiset<E> unmodifiableObservableMultiset(ObservableMultiset<E> multiset) Returns an unmodifiableObservableMultisetwrapping the givenObservableMultiset.- Type Parameters:
- E- The element type of the- ObservableMultiset.
- Parameters:
- multiset- The- ObservableMultisetto wrap.
- Returns:
- An unmodifiable wrapper around the given
         ObservableMultiset.
 
- 
unmodifiableObservableSetMultimappublic static <K,V> ObservableSetMultimap<K,V> unmodifiableObservableSetMultimap(ObservableSetMultimap<K, V> setMultimap) Returns an unmodifiableObservableSetMultimapwrapping the givenObservableSetMultimap.- Type Parameters:
- K- The key type of the- ObservableSetMultimap.
- V- The value type of the- ObservableSetMultimap.
- Parameters:
- setMultimap- The- ObservableSetMultimapto wrap.
- Returns:
- An unmodifiable wrapper around the given
         ObservableSetMultimap.
 
 
-