Class CollectionUtils


  • public class CollectionUtils
    extends java.lang.Object
    Various static helper methods for Collections
    • Method Detail

      • findByIdAndContext

        public static <T extends GetIdentifier & GetContext> T findByIdAndContext​(java.util.Collection<T> c,
                                                                                  java.lang.String identifier,
                                                                                  Context context)
        Looks up an element of a Collection by its identifier (via GetIdentifier) and Context (via GetContext). Returns the first element where the identifier and the context are equal to the parameters.
        Parameters:
        c - The Collection to search
        identifier - The identifier to match
        context - The Context to match
        Returns:
        The first element of the collection where the identifier and the context are equal to the parameters.
      • getListSortedByComparator

        public static <T> java.util.List<T> getListSortedByComparator​(java.util.List<T> l,
                                                                      java.util.Comparator<T> comp)
        Sorts a List by a Comparator and returns the sorted list.
        Parameters:
        l - The list to sort
        comp - The comparator
        Returns:
        The sorted list
        See Also:
        Collections.sort(List, Comparator)