Package kr.toxicity.model.api.util
Class CollectionUtil
java.lang.Object
kr.toxicity.model.api.util.CollectionUtil
Collection util
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunction of floatstatic interfaceFunction with index -
Method Summary
Modifier and TypeMethodDescriptionstatic <E,K> @NotNull @Unmodifiable Map <K, E> associate(@NotNull Collection<E> collection, @NotNull Function<E, K> keyMapper) Associates stream to mapstatic <E,K, V> @NotNull @Unmodifiable Map <K, V> associate(@NotNull Collection<E> collection, @NotNull Function<E, K> keyMapper, @NotNull Function<E, V> valueMapper) Associates collection to mapstatic <E,K> @NotNull @Unmodifiable Map <K, E> Associates stream to mapstatic <E,K, V> @NotNull @Unmodifiable Map <K, V> associate(@NotNull Stream<E> stream, @NotNull Function<E, K> keyMapper, @NotNull Function<E, V> valueMapper) Associates stream to mapstatic <E,R> @NotNull Stream <R> filterIsInstance(@NotNull Collection<E> collection, @NotNull Class<R> rClass) Filters stream by some instancestatic <E,R> @NotNull Stream <R> filterIsInstance(@NotNull Stream<E> stream, @NotNull Class<R> rClass) Filters stream by some instancestatic <T> @NotNull Predicate<T> filterWithWarning(@NotNull Predicate<T> predicate, @NotNull Function<T, String> lazyLogFunction) Gets filter with warning if not matchedGroups stream by some keystatic <E,T extends it.unimi.dsi.fastutil.floats.FloatCollection>
TmapFloat(@NotNull Stream<E> stream, @NotNull CollectionUtil.FloatFunction<E> mapper, @NotNull Supplier<T> creator) Maps some stream to a float collectionstatic <E,R> @NotNull Stream <R> mapIndexed(@NotNull Collection<E> collection, @NotNull CollectionUtil.IndexedFunction<E, R> function) Maps some collection with map indexstatic <K,V, R> @NotNull Stream <R> mapIndexed(@NotNull Map<K, V> map, @NotNull CollectionUtil.IndexedFunction<Map.Entry<K, V>, R> function) Maps some collection with map indexstatic <E,R> @NotNull Stream <R> mapIndexed(@NotNull Stream<E> stream, @NotNull CollectionUtil.IndexedFunction<E, R> function) Maps some collection with map indexstatic <E,R extends com.google.gson.JsonElement>
@NotNull com.google.gson.JsonArrayMaps stream to JSONstatic <E,R extends com.google.gson.JsonElement>
@NotNull com.google.gson.JsonArraymapToJson(@NotNull Collection<E> collection, @NotNull Function<E, R> mapper) Maps stream to JSONstatic <E,R> @NotNull @Unmodifiable List <R> mapToList(@NotNull Collection<E> collection, @NotNull Function<E, R> mapper) Maps stream to liststatic <E,R> @NotNull @Unmodifiable List <R> Maps stream to liststatic <K,V, R> @NotNull @Unmodifiable Map <K, R> Map some map's value.
-
Method Details
-
filterIsInstance
@NotNull public static <E,R> @NotNull Stream<R> filterIsInstance(@NotNull @NotNull Collection<E> collection, @NotNull @NotNull Class<R> rClass) Filters stream by some instance- Type Parameters:
E- elementR- return value- Parameters:
collection- collectionrClass- class of instance- Returns:
- filtered stream
-
mapToList
@NotNull public static <E,R> @NotNull @Unmodifiable List<R> mapToList(@NotNull @NotNull Collection<E> collection, @NotNull @NotNull Function<E, R> mapper) Maps stream to list- Type Parameters:
E- elementR- return value- Parameters:
collection- collectionmapper- mapper- Returns:
- unmodifiable list
-
mapToList
@NotNull public static <E,R> @NotNull @Unmodifiable List<R> mapToList(@NotNull @NotNull Stream<E> stream, @NotNull @NotNull Function<E, R> mapper) Maps stream to list- Type Parameters:
E- elementR- return value- Parameters:
stream- streammapper- mapper- Returns:
- unmodifiable list
-
mapToJson
@NotNull public static <E,R extends com.google.gson.JsonElement> @NotNull com.google.gson.JsonArray mapToJson(@NotNull @NotNull Collection<E> collection, @NotNull @NotNull Function<E, R> mapper) Maps stream to JSON- Type Parameters:
E- elementR- return value- Parameters:
collection- collectionmapper- mapper- Returns:
- JSON array
-
mapToJson
@NotNull public static <E,R extends com.google.gson.JsonElement> @NotNull com.google.gson.JsonArray mapToJson(int capacity, @NotNull @NotNull Stream<E> stream, @NotNull @NotNull Function<E, R> mapper) Maps stream to JSON- Type Parameters:
E- elementR- return value- Parameters:
capacity- initial capacitystream- streammapper- mapper- Returns:
- JSON array
-
filterIsInstance
@NotNull public static <E,R> @NotNull Stream<R> filterIsInstance(@NotNull @NotNull Stream<E> stream, @NotNull @NotNull Class<R> rClass) Filters stream by some instance- Type Parameters:
E- elementR- return value- Parameters:
stream- streamrClass- class of instance- Returns:
- filtered stream
-
group
@NotNull public static <K,E> @NotNull @Unmodifiable Map<K,List<E>> group(@NotNull @NotNull Stream<E> stream, @NotNull @NotNull Function<E, K> keyMapper) Groups stream by some key- Type Parameters:
K- keyE- element- Parameters:
stream- streamkeyMapper- key mapper- Returns:
- unmodifiable grouped map
-
mapIndexed
@NotNull public static <K,V, @NotNull Stream<R> mapIndexedR> (@NotNull @NotNull Map<K, V> map, @NotNull @NotNull CollectionUtil.IndexedFunction<Map.Entry<K, V>, R> function) Maps some collection with map index- Type Parameters:
K- keyV- valueR- return value- Parameters:
map- mapfunction- mapper- Returns:
- mapped stream
-
mapIndexed
@NotNull public static <E,R> @NotNull Stream<R> mapIndexed(@NotNull @NotNull Collection<E> collection, @NotNull @NotNull CollectionUtil.IndexedFunction<E, R> function) Maps some collection with map index- Type Parameters:
E- elementR- return value- Parameters:
collection- collectionfunction- mapper- Returns:
- mapped stream
-
mapIndexed
@NotNull public static <E,R> @NotNull Stream<R> mapIndexed(@NotNull @NotNull Stream<E> stream, @NotNull @NotNull CollectionUtil.IndexedFunction<E, R> function) Maps some collection with map index- Type Parameters:
E- elementR- return value- Parameters:
stream- streamfunction- mapper- Returns:
- mapped stream
-
mapFloat
@NotNull public static <E,T extends it.unimi.dsi.fastutil.floats.FloatCollection> T mapFloat(@NotNull @NotNull Stream<E> stream, @NotNull @NotNull CollectionUtil.FloatFunction<E> mapper, @NotNull @NotNull Supplier<T> creator) Maps some stream to a float collection- Type Parameters:
E- elementT- type- Parameters:
stream- streammapper- mappercreator- float collection creator- Returns:
- float collection
-
mapValue
@NotNull public static <K,V, @NotNull @Unmodifiable Map<K,R> R> mapValue(@NotNull @NotNull Map<K, V> original, @NotNull @NotNull Function<V, R> mapper) Map some map's value.- Type Parameters:
K- keyV- valueR- new value- Parameters:
original- original mapmapper- value mapper- Returns:
- unmodifiable map
-
associate
@NotNull public static <E,K, @NotNull @Unmodifiable Map<K,V> V> associate(@NotNull @NotNull Collection<E> collection, @NotNull @NotNull Function<E, K> keyMapper, @NotNull @NotNull Function<E, V> valueMapper) Associates collection to map- Type Parameters:
E- elementK- keyV- value- Parameters:
collection- collectionkeyMapper- key mappervalueMapper- value mapper- Returns:
- unmodifiable map
-
filterWithWarning
@NotNull public static <T> @NotNull Predicate<T> filterWithWarning(@NotNull @NotNull Predicate<T> predicate, @NotNull @NotNull Function<T, String> lazyLogFunction) Gets filter with warning if not matched- Type Parameters:
T- type- Parameters:
predicate- delegated predicatelazyLogFunction- log function- Returns:
- predicate
-
associate
@NotNull public static <E,K> @NotNull @Unmodifiable Map<K,E> associate(@NotNull @NotNull Collection<E> collection, @NotNull @NotNull Function<E, K> keyMapper) Associates stream to map- Type Parameters:
E- elementK- key- Parameters:
collection- collectionkeyMapper- key mapper- Returns:
- unmodifiable map
-
associate
@NotNull public static <E,K> @NotNull @Unmodifiable Map<K,E> associate(@NotNull @NotNull Stream<E> stream, @NotNull @NotNull Function<E, K> keyMapper) Associates stream to map- Type Parameters:
E- elementK- key- Parameters:
stream- streamkeyMapper- key mapper- Returns:
- unmodifiable map
-
associate
@NotNull public static <E,K, @NotNull @Unmodifiable Map<K,V> V> associate(@NotNull @NotNull Stream<E> stream, @NotNull @NotNull Function<E, K> keyMapper, @NotNull @NotNull Function<E, V> valueMapper) Associates stream to map- Type Parameters:
E- elementK- keyV- value- Parameters:
stream- streamkeyMapper- key mappervalueMapper- value mapper- Returns:
- unmodifiable map
-