Class MindustryCollections
java.lang.Object
com.xpdustry.distributor.api.collection.MindustryCollections
A utility class for wrapping arc collections into standard java collections.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,K, V> Collector<T, ?, arc.struct.ObjectMap<K, V>> collectToObjectMap(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valMapper) Creates aCollectorthat accumulates the elements of a stream into aObjectMap.static <T,K, V> Collector<T, ?, arc.struct.ObjectMap<K, V>> collectToObjectMap(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valMapper, BinaryOperator<V> valMerger) Creates aCollectorthat accumulates the elements of a stream into aObjectMap.static <T,K, V, M extends arc.struct.ObjectMap<K, V>>
Collector<T,?, M> collectToObjectMap(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valMapper, BinaryOperator<V> valMerger, Supplier<M> objectMapFactory) Creates aCollectorthat accumulates the elements of a stream into aObjectMap.static <T,K, V, M extends arc.struct.ObjectMap<K, V>>
Collector<T,?, M> collectToObjectMap(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valMapper, Supplier<M> objectMapFactory) Creates aCollectorthat accumulates the elements of a stream into aObjectMap.static <T> Collector<T,?, arc.struct.ObjectSet<T>> Creates aCollectorthat accumulates the elements of a stream into aObjectSet.static <T,S extends arc.struct.ObjectSet<T>>
Collector<T,?, S> collectToObjectSet(Supplier<S> objectSetFactory) Creates aCollectorthat accumulates the elements of a stream into aObjectSet.static <T> Collector<T,?, arc.struct.Seq<T>> Creates aCollectorthat accumulates the elements of a stream into aSeq.static <T,S extends arc.struct.Seq<T>>
Collector<T,?, S> collectToSeq(Supplier<S> seqFactory) Creates aCollectorthat accumulates the elements of a stream into aSeq.static <E> List<E>immutableList(arc.struct.Seq<E> seq) Wraps aSeqinto an immutableList.static <E extends mindustry.gen.Entityc>
List<E>immutableList(mindustry.entities.EntityGroup<E> group) Wraps anEntityGroupinto an immutableList.static <K,V> Map<K, V> immutableMap(arc.struct.ObjectMap<K, V> map) Wraps anObjectMapinto an immutableMap.static <E> Set<E>immutableSet(arc.struct.ObjectSet<E> seq) Wraps anObjectSetinto an immutableSet.static <E> List<E>mutableList(arc.struct.Seq<E> seq) Wraps aSeqinto aList.static <E extends mindustry.gen.Entityc>
List<E>mutableList(mindustry.entities.EntityGroup<E> group) Wraps anEntityGroupinto aList.static <K,V> Map<K, V> mutableMap(arc.struct.ObjectMap<K, V> map) Wraps anObjectMapinto aMap.static <E> Set<E>mutableSet(arc.struct.ObjectSet<E> seq) Wraps anObjectSetinto aSet.
-
Method Details
-
mutableSet
Wraps anObjectSetinto aSet.- Type Parameters:
E- the element type- Parameters:
seq- the arc set- Returns:
- the wrapped set
-
immutableSet
Wraps anObjectSetinto an immutableSet.- Type Parameters:
E- the element type- Parameters:
seq- the arc set- Returns:
- the wrapped
ObjectSet
-
mutableList
Wraps aSeqinto aList.- Type Parameters:
E- the element type- Parameters:
seq- the arc list- Returns:
- the wrapped
Seq
-
immutableList
Wraps aSeqinto an immutableList.- Type Parameters:
E- the element type- Parameters:
seq- the arc list- Returns:
- the wrapped
Seq
-
mutableList
public static <E extends mindustry.gen.Entityc> List<E> mutableList(mindustry.entities.EntityGroup<E> group) Wraps anEntityGroupinto aList.- Type Parameters:
E- the entity type- Parameters:
group- the entity group- Returns:
- the wrapped
EntityGroup
-
immutableList
public static <E extends mindustry.gen.Entityc> List<E> immutableList(mindustry.entities.EntityGroup<E> group) Wraps anEntityGroupinto an immutableList.- Type Parameters:
E- the entity type- Parameters:
group- the entity group- Returns:
- the wrapped
EntityGroup
-
mutableMap
Wraps anObjectMapinto aMap.- Type Parameters:
K- the key typeV- the value type- Parameters:
map- the arc map- Returns:
- the wrapped
ObjectMap
-
immutableMap
Wraps anObjectMapinto an immutableMap.- Type Parameters:
K- the key typeV- the value type- Parameters:
map- the arc map- Returns:
- the wrapped
ObjectMap
-
collectToSeq
Creates aCollectorthat accumulates the elements of a stream into aSeq.- Type Parameters:
T- the element type- Returns:
- the seq collector
-
collectToSeq
public static <T,S extends arc.struct.Seq<T>> Collector<T,?, collectToSeqS> (Supplier<S> seqFactory) Creates aCollectorthat accumulates the elements of a stream into aSeq.- Type Parameters:
T- the element typeS- the seq type- Parameters:
seqFactory- the seq factory- Returns:
- the seq collector
-
collectToObjectMap
public static <T,K, Collector<T,V> ?, collectToObjectMaparc.struct.ObjectMap<K, V>> (Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valMapper) Creates aCollectorthat accumulates the elements of a stream into aObjectMap. Using the provided key and value mapping function. The collector will throw anIllegalStateExceptionif duplicate keys are encountered.- Type Parameters:
T- the element type- Parameters:
keyMapper- the key mapping functionvalMapper- the value mapping function- Returns:
- the object map collector
-
collectToObjectMap
public static <T,K, Collector<T,V, M extends arc.struct.ObjectMap<K, V>> ?, collectToObjectMapM> (Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valMapper, Supplier<M> objectMapFactory) Creates aCollectorthat accumulates the elements of a stream into aObjectMap. Using the provided key and value mapping function. The collector will throw anIllegalStateExceptionif duplicate keys are encountered.- Type Parameters:
T- the element typeK- the key typeV- the value typeM- the object map type- Parameters:
keyMapper- the key mapping functionvalMapper- the value mapping functionobjectMapFactory- the object map factory- Returns:
- the object map collector
-
collectToObjectMap
public static <T,K, Collector<T,V> ?, collectToObjectMaparc.struct.ObjectMap<K, V>> (Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valMapper, BinaryOperator<V> valMerger) Creates aCollectorthat accumulates the elements of a stream into aObjectMap. Using the provided key and value mapping function.- Type Parameters:
T- the element typeK- the key typeV- the value type- Parameters:
keyMapper- the key mapping functionvalMapper- the value mapping functionvalMerger- the value merger function, in case of duplicate keys- Returns:
- the object map collector
-
collectToObjectMap
public static <T,K, Collector<T,V, M extends arc.struct.ObjectMap<K, V>> ?, collectToObjectMapM> (Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valMapper, BinaryOperator<V> valMerger, Supplier<M> objectMapFactory) Creates aCollectorthat accumulates the elements of a stream into aObjectMap. Using the provided key and value mapping function.- Type Parameters:
T- the element typeK- the key typeV- the value typeM- the object map type- Parameters:
keyMapper- the key mapping functionvalMapper- the value mapping functionvalMerger- the value merger function, in case of duplicate keysobjectMapFactory- the object map factory- Returns:
- the object map collector
-
collectToObjectSet
Creates aCollectorthat accumulates the elements of a stream into aObjectSet.- Type Parameters:
T- the element type- Returns:
- the object set collector
-
collectToObjectSet
public static <T,S extends arc.struct.ObjectSet<T>> Collector<T,?, collectToObjectSetS> (Supplier<S> objectSetFactory) Creates aCollectorthat accumulates the elements of a stream into aObjectSet.- Type Parameters:
T- the element typeS- the object set type- Parameters:
objectSetFactory- the object set factory- Returns:
- the object set collector
-