Class CollectionUtil

java.lang.Object
org.keycloak.common.util.CollectionUtil

public class CollectionUtil extends Object
Author:
Jeroen Rosenberg
  • Constructor Details

    • CollectionUtil

      public CollectionUtil()
  • Method Details

    • join

      public static String join(Collection<String> strings)
    • join

      public static String join(Collection<String> strings, String separator)
    • collectionEquals

      public static <T> boolean collectionEquals(Collection<T> col1, Collection<T> col2)
    • isEmpty

      public static boolean isEmpty(Collection<?> collection)
    • isNotEmpty

      public static boolean isNotEmpty(Collection<?> collection)
    • collectionToSet

      public static <T> Set<T> collectionToSet(Collection<T> collection)
    • partition

      public static <T> List<List<T>> partition(Collection<T> items, int chunkSize)
      Splits the given collection into consecutive chunks of at most chunkSize elements, preserving iteration order. Every chunk except possibly the last has exactly chunkSize elements. The returned chunks are independent copies and do not reference the source collection.
      Parameters:
      items - the collection to split; may be null
      chunkSize - the maximum number of elements per chunk; must be greater than 0
      Returns:
      list of chunks; an empty list if items is null or empty
      Throws:
      IllegalArgumentException - if chunkSize is not positive