Class USet

java.lang.Object
ushiosan.jvm.collections.USet

public final class USet extends Object
  • Method Details

    • make

      @SafeVarargs @NotNull public static <T> @Unmodifiable @NotNull Set<T> make(T @NotNull ... elements)
      Create a set with all given elements.
      Type Parameters:
      T - generic type set
      Parameters:
      elements - the elements to insert
      Returns:
      a set with all elements
    • make

      @NotNull public static <T> @Unmodifiable @NotNull Set<T> make(@NotNull @NotNull Collection<T> base)
      Create a set with all given elements.
      Type Parameters:
      T - generic type set
      Parameters:
      base - the base collection content
      Returns:
      a set with all elements
    • makeMutable

      @SafeVarargs @NotNull public static <T> @NotNull Set<T> makeMutable(T @NotNull ... elements)
      Create a mutable set with all given elements.
      Type Parameters:
      T - generic type set
      Parameters:
      elements - the elements to insert
      Returns:
      a set with all elements
    • makeMutable

      @NotNull public static <T> @NotNull Set<T> makeMutable(@NotNull @NotNull Collection<T> base)
      Create a mutable set with all given elements.
      Type Parameters:
      T - generic type set
      Parameters:
      base - the base collection content
      Returns:
      a set with all elements
    • makeLinked

      @SafeVarargs @NotNull public static <T> @NotNull Set<T> makeLinked(T @NotNull ... elements)
      Create a linked set with all given elements.
      Type Parameters:
      T - generic type set
      Parameters:
      elements - the elements to insert
      Returns:
      a linked set with all elements
    • makeLinked

      @NotNull public static <T> @NotNull Set<T> makeLinked(@NotNull @NotNull Collection<T> base)
      Create a linked set with all given elements.
      Type Parameters:
      T - generic type set
      Parameters:
      base - the base collection content
      Returns:
      a linked set with all elements
    • makeTree

      @SafeVarargs @NotNull public static <T> @NotNull Set<T> makeTree(@Nullable @Nullable Comparator<T> comparator, T @NotNull ... elements)
      Create a tree set with all given elements.
      Type Parameters:
      T - generic type set
      Parameters:
      comparator - the set comparator (used to sort the elements)
      elements - the elements to insert
      Returns:
      a tree set with all elements
    • makeTree

      @SafeVarargs @NotNull public static <T> @NotNull Set<T> makeTree(T @NotNull ... elements)
      Create a tree set with all given elements.
      Type Parameters:
      T - generic type set
      Parameters:
      elements - the elements to insert
      Returns:
      a linked set with all elements
    • makeTree

      @NotNull public static <T> @NotNull Set<T> makeTree(@Nullable @Nullable Comparator<T> comparator, @NotNull @NotNull Collection<T> base)
      Create a linked set with all given elements.
      Type Parameters:
      T - generic type set
      Parameters:
      comparator - sort comparator instance
      base - the base collection content
      Returns:
      a linked set with all elements
    • makeEnum

      @NotNull public static <T extends Enum<T>> @NotNull Set<T> makeEnum(@NotNull @NotNull Class<T> cls)
      Create an enum set with all enum elements.
      Type Parameters:
      T - generic enum type
      Parameters:
      cls - the enum class to check
      Returns:
      an enum set with all enum elements
    • combine

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

      @NotNull public static <T, R> @NotNull Set<R> transform(@NotNull @NotNull Set<T> original, @NotNull @NotNull Function<T,R> mapper)
      Converts one set to another but with a different data type.
      Type Parameters:
      T - the original data type
      R - the target data type
      Parameters:
      original - the original set that you want to convert
      mapper - function in charge of transforming each element of the set
      Returns:
      the new set 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