Class CollectionUtils

    • Constructor Detail

      • CollectionUtils

        public CollectionUtils()
    • Method Detail

      • getPermutation

        public static <E> int[] getPermutation​(javafx.collections.ListChangeListener.Change<? extends E> change)
        Computes the permutation for the given ListChangeListener.Change.
        Type Parameters:
        E - The element type of the ObservableList that 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.
      • getPreviousContents

        public 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.
        Type Parameters:
        E - The element type of the ObservableList.
        Parameters:
        change - The ListChangeListener.Change for which to compute the previous contents.
        Returns:
        A newly created List that resembles the state of the source ObservableList before the change.
      • observableArrayList

        public static <E> javafx.collections.ObservableList<E> observableArrayList()
        Returns a (modifiable) new 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).
        Type Parameters:
        E - The element type of the ObservableList. The List to wrap.
        Returns:
        An ObservableList wrapping the given List.
      • observableArrayList

        public 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.
        Type Parameters:
        E - The element type of the ObservableList.
        Parameters:
        collection - The Collection that provides the initial contents of the to be created ObservableList.
        Returns:
        A new ObservableList containing the given contents.
      • observableArrayList

        public static <E> javafx.collections.ObservableList<E> observableArrayList​(E... elements)
        Creates a new ObservableList that 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
      • observableList

        public static <E> javafx.collections.ObservableList<E> observableList​(java.util.List<E> list)
        Returns a (modifiable) new 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).
        Type Parameters:
        E - The element type of the ObservableList.
        Parameters:
        list - The List to wrap.
        Returns:
        An ObservableList wrapping the given List.
      • sort

        public static <E extends java.lang.Comparable<? super E>> void sort​(javafx.collections.ObservableList<E> observableList)
        Sorts the given ObservableList using the default Comparator .
        Type Parameters:
        E - The value type of the ObservableList.
        Parameters:
        observableList - The ObservableList to sort.
      • sort

        public static <E> void sort​(javafx.collections.ObservableList<E> observableList,
                                    java.util.Comparator<? super E> comparator)
        Sorts the given ObservableList using the given Comparator .
        Type Parameters:
        E - The value type of the ObservableList.
        Parameters:
        observableList - The ObservableList to sort.
        comparator - The Comparator to use.