@Beta @NonNullByDefault public final class CollectionWrappers extends Object
Modifier and Type | Method and Description |
---|---|
static <E> List<E> |
wrapAsList(Collection<E> collection)
Wrap the specified
Collection as a List . |
static <E> Set<E> |
wrapAsSet(Collection<E> collection)
Wrap the specified
Collection as a Set . |
public static <E> List<E> wrapAsList(Collection<E> collection)
Collection
as a List
. If the collection is already a List, it is wrapped in
a Collections.unmodifiableList(List)
to prevent mutability leaking. If the collection is determined
to be empty, an empty list is returned instead. If the collection is a known-immutable implementation of List
interface, it is returned unwrapped. Backing collection is required to be effectively immutable. If this
requirement is violated, the returned object may behave in unpredictable ways.collection
- Collection to be wrappedNullPointerException
- if collection is nullpublic static <E> Set<E> wrapAsSet(Collection<E> collection)
Collection
as a Set
. If the collection is already a Set, it is wrapped in
a Collections.unmodifiableSet(Set)
to prevent mutability leaking. If the collection is determined
to be empty, an empty set is returned instead. If the collection is a known-immutable implementation of Set
interface, it is returned unwrapped. The collection is checked for duplicates at instantiation time, such that
it effectively implements the Set contract. Backing collection is required to be effectively immutable. If this
requirement is violated, the returned object may behave in unpredictable ways.collection
- Collection to be wrappedNullPointerException
- if collection is null or any of its elements is nullIllegalArgumentException
- if the collection's contents do not conform to the Set contractCopyright © 2019 OpenDaylight. All rights reserved.