Class CollectionUtils


  • public final class CollectionUtils
    extends java.lang.Object
    Utility class for collections.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.List<T> buildOrderedConfigPriorities​(java.util.List<T> configPriorityList, boolean ascending)
      Sorts the list based on the annotation ConfigPriority.
      static <T> java.util.function.Predicate<T> distinctBy​(java.util.function.Function<? super T,​java.lang.Object> valueExtractor)
      Returns a distinct list based on the value Extractor.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • distinctBy

        public static <T> java.util.function.Predicate<T> distinctBy​(java.util.function.Function<? super T,​java.lang.Object> valueExtractor)
        Returns a distinct list based on the value Extractor.
        Type Parameters:
        T - the type of the collection
        Parameters:
        valueExtractor - function to extract the value we are looking for distinct.
        Returns:
        the list of districts
      • buildOrderedConfigPriorities

        public static <T> java.util.List<T> buildOrderedConfigPriorities​(java.util.List<T> configPriorityList,
                                                                         boolean ascending)
        Sorts the list based on the annotation ConfigPriority. if the object is missing the annotation it will not be included.
        Type Parameters:
        T - generic type
        Parameters:
        configPriorityList - list of config priorities
        ascending - if we should sort ascending
        Returns:
        list of ordered ConfigPriority based on value, if value is missing it will be omitted