Package nl.vpro.domain.media
Class CollectionUtils
java.lang.Object
nl.vpro.domain.media.CollectionUtils
Some static methods used in this package that are related to dealing with collections
- Since:
- 5.12
- Author:
- Michiel Meeuwissen
-
Method Summary
Modifier and TypeMethodDescriptionstatic <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
static <E> int
removeIf
(Collection<E> collection, Predicate<? super E> filter) LikeCollection.removeIf(Predicate)
but returns the number of removed items.
-
Method Details
-
getFromList
-
indexOf
-
createIfNull
-
createIfNullUnlessNull
public static <P extends Comparable<P>> @Nullable SortedSet<P> createIfNullUnlessNull(@Nullable SortedSet<P> set, @Nullable Object check) -
inCollection
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
-
removeIf
LikeCollection.removeIf(Predicate)
but returns the number of removed items. TODO it seems odd that we would be the first to wan this? Guava?- Since:
- 7.10
-