Package net.shibboleth.shared.collection

# Class CollectionSupport

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

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

## Field Summary

Fields
Modifier and Type
Field
Description
`private static org.slf4j.Logger`
`log`
logger.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`private`
`CollectionSupport()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static <T> List<T>`
`arrayAsList(T... a)`
Creates a mutable List from an array.
`static <T> List<T>`
`copyToList(Collection<? extends T> coll)`
Copies a collection to a list with non-null guarantee.
`static <U, T> Map<U,T>`
`copyToMap(Map<? extends U,? extends T> map)`
Copies a map to a map with non-null guarantee.
`static <T> Set<T>`
`copyToSet(Collection<? extends T> coll)`
Copies a collection to a set with non-null guarantee.
`static <T> List<T>`
`emptyList()`
Gets an empty list with non-null guarantee.
`static <T, U> Map<T,U>`
`emptyMap()`
Gets an empty map with non-null guarantee.
`static <T> Set<T>`
`emptySet()`
Gets an empty set with non-null guarantee.
`static <T> List<T>`
`listOf()`
Gets a zero member list with non-null guarantee.
`static <T> List<T>`
`listOf(T first)`
Gets a one member list with non-null guarantee.
`static <T> List<T>`
`listOf(T... elements)`
Gets a list with non-null guarantee and a variable number of members.
`static <T> List<T>`
`listOf(T first, T second)`
Gets a two member list with non-null guarantee.
`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.
`static <T> Set<T>`
`setOf()`
Gets a zero member set with non-null guarantee.
`static <T> Set<T>`
`setOf(T first)`
Gets a one member set with non-null guarantee.
`static <T> Set<T>`
`setOf(T... elements)`
Gets a set with non-null guarantee and a variable number of members.
`static <T> Set<T>`
`setOf(T first, T second)`
Gets a two member set with non-null guarantee.
`static <T> Set<T>`
`singleton(T item)`
Gets a singleton set with non-null guarantee.
`static <T> List<T>`
`singletonList(T item)`
Gets a singleton list with non-null guarantee.
`static <T, U> Map<T,U>`
`singletonMap(T key, U value)`
Gets a singleton map with non-null guarantee.
`static <T> BinaryOperator<T>`
`warningMergeFunction(String what, boolean takeFirst)`
Build something we can plug in into `Collectors.toMap(java.util.function.Function, java.util.function.Function, BinaryOperator)`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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)
Build something we can plug in into `Collectors.toMap(java.util.function.Function, java.util.function.Function, BinaryOperator)`.

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`