Class MindustryCollections

java.lang.Object
com.xpdustry.distributor.api.collection.MindustryCollections

public final class MindustryCollections extends Object
A utility class for wrapping arc collections into standard java collections.
  • Method Details

    • mutableSet

      public static <E> Set<E> mutableSet(arc.struct.ObjectSet<E> seq)
      Wraps an ObjectSet into a Set.
      Type Parameters:
      E - the element type
      Parameters:
      seq - the arc set
      Returns:
      the wrapped set
    • immutableSet

      public static <E> Set<E> immutableSet(arc.struct.ObjectSet<E> seq)
      Wraps an ObjectSet into an immutable Set.
      Type Parameters:
      E - the element type
      Parameters:
      seq - the arc set
      Returns:
      the wrapped ObjectSet
    • mutableList

      public static <E> List<E> mutableList(arc.struct.Seq<E> seq)
      Wraps a Seq into a List.
      Type Parameters:
      E - the element type
      Parameters:
      seq - the arc list
      Returns:
      the wrapped Seq
    • immutableList

      public static <E> List<E> immutableList(arc.struct.Seq<E> seq)
      Wraps a Seq into an immutable List.
      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 an EntityGroup into a List.
      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 an EntityGroup into an immutable List.
      Type Parameters:
      E - the entity type
      Parameters:
      group - the entity group
      Returns:
      the wrapped EntityGroup
    • mutableMap

      public static <K, V> Map<K,V> mutableMap(arc.struct.ObjectMap<K,V> map)
      Wraps an ObjectMap into a Map.
      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      map - the arc map
      Returns:
      the wrapped ObjectMap
    • immutableMap

      public static <K, V> Map<K,V> immutableMap(arc.struct.ObjectMap<K,V> map)
      Wraps an ObjectMap into an immutable Map.
      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      map - the arc map
      Returns:
      the wrapped ObjectMap
    • collectToSeq

      public static <T> Collector<T,?,arc.struct.Seq<T>> collectToSeq()
      Creates a Collector that accumulates the elements of a stream into a Seq.
      Type Parameters:
      T - the element type
      Returns:
      the seq collector
    • collectToSeq

      public static <T, S extends arc.struct.Seq<T>> Collector<T,?,S> collectToSeq(Supplier<S> seqFactory)
      Creates a Collector that accumulates the elements of a stream into a Seq.
      Type Parameters:
      T - the element type
      S - the seq type
      Parameters:
      seqFactory - the seq factory
      Returns:
      the seq collector
    • collectToObjectMap

      public static <T, K, V> Collector<T,?,arc.struct.ObjectMap<K,V>> collectToObjectMap(Function<? super T,? extends K> keyMapper, Function<? super T,? extends V> valMapper)
      Creates a Collector that accumulates the elements of a stream into a ObjectMap. Using the provided key and value mapping function. The collector will throw an IllegalStateException if duplicate keys are encountered.
      Type Parameters:
      T - the element type
      Parameters:
      keyMapper - the key mapping function
      valMapper - the value mapping function
      Returns:
      the object map collector
    • collectToObjectMap

      public 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 a Collector that accumulates the elements of a stream into a ObjectMap. Using the provided key and value mapping function. The collector will throw an IllegalStateException if duplicate keys are encountered.
      Type Parameters:
      T - the element type
      K - the key type
      V - the value type
      M - the object map type
      Parameters:
      keyMapper - the key mapping function
      valMapper - the value mapping function
      objectMapFactory - the object map factory
      Returns:
      the object map collector
    • collectToObjectMap

      public 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 a Collector that accumulates the elements of a stream into a ObjectMap. Using the provided key and value mapping function.
      Type Parameters:
      T - the element type
      K - the key type
      V - the value type
      Parameters:
      keyMapper - the key mapping function
      valMapper - the value mapping function
      valMerger - the value merger function, in case of duplicate keys
      Returns:
      the object map collector
    • collectToObjectMap

      public 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 a Collector that accumulates the elements of a stream into a ObjectMap. Using the provided key and value mapping function.
      Type Parameters:
      T - the element type
      K - the key type
      V - the value type
      M - the object map type
      Parameters:
      keyMapper - the key mapping function
      valMapper - the value mapping function
      valMerger - the value merger function, in case of duplicate keys
      objectMapFactory - the object map factory
      Returns:
      the object map collector
    • collectToObjectSet

      public static <T> Collector<T,?,arc.struct.ObjectSet<T>> collectToObjectSet()
      Creates a Collector that accumulates the elements of a stream into a ObjectSet.
      Type Parameters:
      T - the element type
      Returns:
      the object set collector
    • collectToObjectSet

      public static <T, S extends arc.struct.ObjectSet<T>> Collector<T,?,S> collectToObjectSet(Supplier<S> objectSetFactory)
      Creates a Collector that accumulates the elements of a stream into a ObjectSet.
      Type Parameters:
      T - the element type
      S - the object set type
      Parameters:
      objectSetFactory - the object set factory
      Returns:
      the object set collector