Class CollectionUtils
- java.lang.Object
-
- org.eclipse.gef.common.collections.CollectionUtils
-
public class CollectionUtils extends java.lang.ObjectTheCollectionUtilscontains a method to compute the old value of anObservableListfor a givenListChangeListener.Changeevent. For details, seegetPreviousContents(javafx.collections.ListChangeListener.Change).
-
-
Constructor Summary
Constructors Constructor Description CollectionUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <E> ObservableMultiset<E>emptyMultiset()Returns an empty, unmodifiableObservableMultiset.static <K,V>
ObservableSetMultimap<K,V>emptySetMultimap()Returns an empty, unmodifiableObservableSetMultimap.static <E> int[]getPermutation(javafx.collections.ListChangeListener.Change<? extends E> change)Computes the permutation for the givenListChangeListener.Change.static <E> java.util.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>observableArrayList()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(java.util.Collection<? extends E> collection)Create a newObservableListthat is backed by anArrayListthat contains the contents of the givenCollection.static <K,V>
ObservableSetMultimap<K,V>observableHashMultimap()Returns a (modifiable) newObservableSetMultimapwrapping aHashMultimap.static <E> ObservableMultiset<E>observableHashMultiset()Returns a (modifiable) newObservableMultisetwrapping aHashMultiset.static <E> javafx.collections.ObservableList<E>observableList(java.util.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 java.lang.Comparable<? super E>>
voidsort(javafx.collections.ObservableList<E> observableList)Sorts the givenObservableListusing the defaultComparator.static <E> voidsort(javafx.collections.ObservableList<E> observableList, java.util.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.
-
-
-
Method Detail
-
emptyMultiset
public static <E> ObservableMultiset<E> emptyMultiset()
Returns an empty, unmodifiableObservableMultiset.- Type Parameters:
E- The element type of theObservableMultiset.- Returns:
- An empty, unmodifiable
ObservableMultiset.
-
emptySetMultimap
public static <K,V> ObservableSetMultimap<K,V> 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> java.util.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).- Type Parameters:
E- The element type of theObservableList. TheListto wrap.- Returns:
- An
ObservableListwrapping the givenList.
-
observableArrayList
public static <E> javafx.collections.ObservableList<E> observableArrayList(java.util.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
public static <K,V> ObservableSetMultimap<K,V> 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
public static <E> ObservableMultiset<E> observableHashMultiset()
Returns a (modifiable) newObservableMultisetwrapping aHashMultiset.- Type Parameters:
E- The element type of theObservableList.- Returns:
- An
ObservableMultisetwrapping aHashMultiset.
-
observableList
public static <E> javafx.collections.ObservableList<E> observableList(java.util.List<E> list)
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).- Type Parameters:
E- The element type of theObservableList.- Parameters:
list- TheListto wrap.- Returns:
- An
ObservableListwrapping the givenList.
-
observableMultiset
public static <E> ObservableMultiset<E> observableMultiset(Multiset<E> multiset)
Returns a (modifiable) newObservableMultisetwrapping the givenList.- Type Parameters:
E- The element type of theObservableList.- Parameters:
multiset- TheMultisetto wrap.- Returns:
- An
ObservableMultisetwrapping the givenList.
-
observableSetMultimap
public static <K,V> ObservableSetMultimap<K,V> observableSetMultimap(SetMultimap<K,V> setMultimap)
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 java.lang.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, java.util.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.
-
-