Class CollectionSupport

java.lang.Object
net.shibboleth.shared.collection.CollectionSupport

public final class CollectionSupport extends Object
Support functions for Collection and Map Management.
  • Field Details

    • log

      @Nonnull private static org.slf4j.Logger log
      logger.
  • Constructor Details

    • CollectionSupport

      private CollectionSupport()
      Constructor.
  • Method Details

    • warningMergeFunction

      @Nonnull public static <T> BinaryOperator<T> warningMergeFunction(String what, boolean takeFirst)
      Type Parameters:
      T - the type we'll be looking at
      Parameters:
      what - What we are building (i.e. IdpUI)
      takeFirst - do we want the first of the last to win.
      Returns:
      an appropriate BinaryOperator
    • nonnullCollector

      public static <T, A, R> Collector<T,A,NonnullSupplier<R>> nonnullCollector(Collector<T,A,R> collector)
      Return a collector which collects to a NonnullSupplier whose content is the value returned by the collector you were given.
      Type Parameters:
      T - the type of input elements to the reduction operation of the collector
      A - the mutable accumulation type of the reduction operation of the collector (often hidden as an implementation detail)
      R - the result type of the reduction operation of the collector
      Parameters:
      collector - the collector
      Returns:
      the NonnullSupplier.
    • emptyList

      @Nonnull @Unmodifiable @NotLive public static <T> List<T> emptyList()
      Gets an empty list with non-null guarantee.
      Type Parameters:
      T - list type
      Returns:
      empty list
    • singletonList

      @Nonnull @Unmodifiable @NotLive public static <T> List<T> singletonList(@Nonnull T item)
      Gets a singleton list with non-null guarantee.
      Type Parameters:
      T - list type
      Parameters:
      item - the single item
      Returns:
      singleton list
    • listOf

      @Nonnull @Unmodifiable @NotLive public static <T> List<T> listOf()
      Gets a zero member list with non-null guarantee.
      Type Parameters:
      T - list type
      Returns:
      zero member list
    • listOf

      @Nonnull @Unmodifiable @NotLive public static <T> List<T> listOf(@Nonnull T first)
      Gets a one member list with non-null guarantee.
      Type Parameters:
      T - list type
      Parameters:
      first - the first item
      Returns:
      a singleton list
    • listOf

      @Nonnull @Unmodifiable @NotLive public static <T> List<T> listOf(@Nonnull T first, @Nonnull T second)
      Gets a two member list with non-null guarantee.
      Type Parameters:
      T - list type
      Parameters:
      first - the first item
      second - the second item
      Returns:
      two member list
    • listOf

      @SafeVarargs @Nonnull @Unmodifiable @NotLive public static <T> List<T> listOf(@Nonnull T... elements)
      Gets a list with non-null guarantee and a variable number of members.
      Type Parameters:
      T - list type
      Parameters:
      elements - the elements
      Returns:
      multi member list
    • copyToList

      @Nonnull @Unmodifiable @NotLive public static <T> List<T> copyToList(@Nonnull Collection<? extends T> coll)
      Copies a collection to a list with non-null guarantee.
      Type Parameters:
      T - list type
      Parameters:
      coll - collection to copy
      Returns:
      immutable copied list
    • emptySet

      @Nonnull @Unmodifiable @NotLive public static <T> Set<T> emptySet()
      Gets an empty set with non-null guarantee.
      Type Parameters:
      T - set type
      Returns:
      empty set
    • singleton

      @Nonnull @Unmodifiable @NotLive public static <T> Set<T> singleton(@Nonnull T item)
      Gets a singleton set with non-null guarantee.
      Type Parameters:
      T - set type
      Parameters:
      item - the single item
      Returns:
      singleton set
    • setOf

      @Nonnull @Unmodifiable @NotLive public static <T> Set<T> setOf()
      Gets a zero member set with non-null guarantee.
      Type Parameters:
      T - list type
      Returns:
      zero member set
    • setOf

      @Nonnull @Unmodifiable @NotLive public static <T> Set<T> setOf(@Nonnull T first)
      Gets a one member set with non-null guarantee.
      Type Parameters:
      T - list type
      Parameters:
      first - the first item
      Returns:
      one member set
    • setOf

      @Nonnull @Unmodifiable @NotLive public static <T> Set<T> setOf(@Nonnull T first, @Nonnull T second)
      Gets a two member set with non-null guarantee.
      Type Parameters:
      T - list type
      Parameters:
      first - the first item
      second - the second item
      Returns:
      two member set
    • setOf

      @SafeVarargs @Nonnull @Unmodifiable @NotLive public static <T> Set<T> setOf(@Nonnull T... elements)
      Gets a set with non-null guarantee and a variable number of members.
      Type Parameters:
      T - list type
      Parameters:
      elements - the elements
      Returns:
      multi member set
    • copyToSet

      @Nonnull @Unmodifiable @NotLive public static <T> Set<T> copyToSet(@Nonnull Collection<? extends T> coll)
      Copies a collection to a set with non-null guarantee.
      Type Parameters:
      T - set type
      Parameters:
      coll - collection to copy
      Returns:
      immutable copied set
    • emptyMap

      @Nonnull @Unmodifiable @NotLive public static <T, U> Map<T,U> emptyMap()
      Gets an empty map with non-null guarantee.
      Type Parameters:
      T - key type
      U - value type
      Returns:
      empty amp
    • singletonMap

      @Nonnull @Unmodifiable @NotLive public static <T, U> Map<T,U> singletonMap(@Nonnull T key, @Nullable U value)
      Gets a singleton map with non-null guarantee.
      Type Parameters:
      T - key type
      U - value type
      Parameters:
      key - map key
      value - map value
      Returns:
      singleton amp
    • copyToMap

      @Nonnull @Unmodifiable @NotLive public static <U, T> Map<U,T> copyToMap(@Nonnull Map<? extends U,? extends T> map)
      Copies a map to a map with non-null guarantee.
      Type Parameters:
      U - key type
      T - value type
      Parameters:
      map - map to copy
      Returns:
      immutable copied map
    • arrayAsList

      @SafeVarargs @Nonnull @Unmodifiable @NotLive public static <T> List<T> arrayAsList(@Nonnull T... a)
      Creates a mutable List from an array.
      Type Parameters:
      T - the class of the objects in the array
      Parameters:
      a - the array by which the list will be backed
      Returns:
      a list view of the specified array
      Throws:
      NullPointerException - if the specified array is null