Package com.dianxin.tori.base.utils
Class CollectionUtils
java.lang.Object
com.dianxin.tori.base.utils.CollectionUtils
Utility class providing conversion helpers for collections with mutable and unmodifiable variants.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @NotNull List<T> toList(@Nullable Collection<T> collection) Converts a collection into a mutableList.static <T> @NotNull Set<T> toSet(@Nullable Collection<T> collection) Converts a collection into a mutableSet.static <T> @NotNull @Unmodifiable List<T> toUnmodifiableList(@Nullable Collection<T> collection) Converts a collection into an unmodifiableList.static <T> @NotNull @Unmodifiable Set<T> toUnmodifiableSet(@Nullable Collection<T> collection) Converts a collection into an unmodifiableSet.
-
Method Details
-
toSet
Converts a collection into a mutableSet.- Type Parameters:
T- the element type- Parameters:
collection- the source collection, can benull- Returns:
- a mutable
HashSetcontaining unique elements, or an empty set if the input isnullor empty
-
toUnmodifiableSet
@NotNull public static <T> @NotNull @Unmodifiable Set<T> toUnmodifiableSet(@Nullable @Nullable Collection<T> collection) Converts a collection into an unmodifiableSet. -
toList
Converts a collection into a mutableList.- Type Parameters:
T- the element type- Parameters:
collection- the source collection, can benull- Returns:
- a mutable
ArrayList, or an empty list if the input isnullor empty
-
toUnmodifiableList
@NotNull public static <T> @NotNull @Unmodifiable List<T> toUnmodifiableList(@Nullable @Nullable Collection<T> collection) Converts a collection into an unmodifiableList.
-