Package nl.vpro.domain.media
Class CollectionUtils
- java.lang.Object
-
- nl.vpro.domain.media.CollectionUtils
-
public class CollectionUtils extends Object
Some static methods used in this package that are related to dealing with collections- Since:
- 5.12
- Author:
- Michiel Meeuwissen
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <P extends Comparable<P>>
SortedSet<P>createIfNull(SortedSet<P> set)
static <P extends Comparable<P>>
@Nullable SortedSet<P>createIfNullUnlessNull(@Nullable SortedSet<P> set, @Nullable Object check)
protected static <E> @Nullable E
getFromList(@Nullable List<@NonNull E> list)
static <P> boolean
inCollection(Collection<P> col, P element)
null
-safeCollection.contains(Object)
.static <E> int
indexOf(List<E> list, E o, int offset)
-
-
-
Method Detail
-
getFromList
protected static <E> @Nullable E getFromList(@Nullable List<@NonNull E> list)
-
indexOf
public static <E> int indexOf(List<E> list, E o, int offset)
-
createIfNull
public static <P extends Comparable<P>> SortedSet<P> createIfNull(SortedSet<P> set)
-
createIfNullUnlessNull
public static <P extends Comparable<P>> @Nullable SortedSet<P> createIfNullUnlessNull(@Nullable SortedSet<P> set, @Nullable Object check)
-
inCollection
public static <P> boolean inCollection(Collection<P> col, P element)
null
-safeCollection.contains(Object)
.null
is never in the list.Mainly because link java 9's Immutable lists resulting from things as
List.of()
throw exception if called withnull
(Things likeCollections.unmodifiableList(List)
didn't behave like that).- Since:
- 7.2
-
-