Class UMap

java.lang.Object
ushiosan.jvm.collections.UMap

public class UMap extends Object
  • Method Details

    • make

      @Contract(pure=true) @SafeVarargs @NotNull public static <K, V> @UnmodifiableView @NotNull Map<K,V> make(Map.Entry<K,V> @NotNull ... entries)
      Create a read-only map with all the given elements.
      Type Parameters:
      K - key entry type
      V - value entry type
      Parameters:
      entries - the elements to insert
      Returns:
      a read-only map with all content
    • make

      @Contract(pure=true) @SafeVarargs @NotNull public static <K, V> @UnmodifiableView @NotNull Map<K,V> make(UPair<K,V> @NotNull ... pairs)
      Create a read-only map with all the given elements.
      Type Parameters:
      K - key entry type
      V - value entry type
      Parameters:
      pairs - the elements to insert
      Returns:
      a read-only map with all content
    • makeMutable

      @SafeVarargs @NotNull public static <K, V> @NotNull Map<K,V> makeMutable(Map.Entry<K,V> @NotNull ... entries)
      Create a mutable map with all the given elements.
      Type Parameters:
      K - key entry type
      V - value entry type
      Parameters:
      entries - the elements to insert
      Returns:
      a mutable map with all content
    • makeMutable

      @SafeVarargs @NotNull public static <K, V> @NotNull Map<K,V> makeMutable(UPair<K,V> @NotNull ... pairs)
      Create a mutable map with all the given elements.
      Type Parameters:
      K - key entry type
      V - value entry type
      Parameters:
      pairs - the elements to insert
      Returns:
      a mutable map with all content
    • makeWeak

      @SafeVarargs @NotNull public static <K, V> @NotNull Map<K,V> makeWeak(Map.Entry<K,V> @NotNull ... entries)
      Create a mutable map with all the given elements.
      Type Parameters:
      K - key entry type
      V - value entry type
      Parameters:
      entries - the elements to insert
      Returns:
      a mutable map with all content
    • makeWeak

      @SafeVarargs @NotNull public static <K, V> @NotNull Map<K,V> makeWeak(UPair<K,V> @NotNull ... pairs)
      Create a mutable map with all the given elements.
      Type Parameters:
      K - key entry type
      V - value entry type
      Parameters:
      pairs - the elements to insert
      Returns:
      a mutable map with all content
    • makeLinked

      @SafeVarargs @NotNull public static <K, V> @NotNull Map<K,V> makeLinked(Map.Entry<K,V> @NotNull ... entries)
      Create a mutable map with all the given elements.
      Type Parameters:
      K - key entry type
      V - value entry type
      Parameters:
      entries - the elements to insert
      Returns:
      a mutable map with all content
    • makeLinked

      @SafeVarargs @NotNull public static <K, V> @NotNull Map<K,V> makeLinked(UPair<K,V> @NotNull ... pairs)
      Create a mutable map with all the given elements.
      Type Parameters:
      K - key entry type
      V - value entry type
      Parameters:
      pairs - the elements to insert
      Returns:
      a mutable map with all content
    • transform

      @NotNull public static <K, V, KR, VR> @NotNull Map<KR,VR> transform(@NotNull @NotNull Map<K,V> original, @NotNull @NotNull Function<Map.Entry<K,V>,Map.Entry<KR,VR>> mapper)
      Converts one map to another but with a different data type.
      Type Parameters:
      K - base entry key value type
      V - base entry value type
      KR - output entry key value type
      VR - output entry value type
      Parameters:
      original - the original map that you want to convert
      mapper - function in charge of transforming each element of the map
      Returns:
      the new map with the converted data
    • transformPair

      @NotNull public static <K, V, KR, VR> @NotNull Map<KR,VR> transformPair(@NotNull @NotNull Map<K,V> original, @NotNull @NotNull Function<UPair<K,V>,UPair<KR,VR>> mapper)
      Converts one map to another but with a different data type.
      Type Parameters:
      K - base entry key value type
      V - base entry value type
      KR - output entry key value type
      VR - output entry value type
      Parameters:
      original - the original map that you want to convert
      mapper - function in charge of transforming each element of the map
      Returns:
      the new map with the converted data
    • isUnmodifiable

      public static boolean isUnmodifiable(@NotNull @NotNull Collection<?> collection)
      Check if the inspected collection supports the modification of its data
      Parameters:
      collection - the collection of data you want to inspect
      Returns:
      true if the collection is immutable or false otherwise
    • isUnmodifiable

      public static boolean isUnmodifiable(@NotNull @NotNull Map<?,?> map)
      Check if the inspected collection supports the modification of its data
      Parameters:
      map - the map of data you want to inspect
      Returns:
      true if the collection is immutable or false otherwise
    • combine

      @SafeVarargs @NotNull public static <T> @NotNull Collection<T> combine(boolean excludeDuplicates, List<T> @NotNull ... lts)
      Combine different lists into a single collection
      Type Parameters:
      T - generic collection type
      Parameters:
      excludeDuplicates - remove all duplicate items
      lts - the lists you want to merge
      Returns:
      returns a single collection with all the elements of the passed lists
    • combine

      @SafeVarargs @NotNull public static <T> @NotNull Collection<T> combine(List<T> @NotNull ... lts)
      Combine different lists into a single collection
      Type Parameters:
      T - generic collection type
      Parameters:
      lts - the lists you want to merge
      Returns:
      returns a single collection with all the elements of the passed lists