Class Sets


  • public class Sets
    extends java.lang.Object
    Set Utility
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.Set<T> create()
      Creates a new HashSet instance.
      static <T> T first​(java.util.Set<T> set)
      Returns the first element in the Set, or null if the Set is empty.
      static <T> java.util.Set<T> from​(java.lang.Iterable<T> entries)
      Creates a Set from an Iterable.
      static <T> T[] toArray​(java.util.Set<T> set)
      Converts a Set into a List.
      static <T> java.util.List<T> toList​(java.util.Set<T> set)
      Converts a Set into a List.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • create

        public static <T> java.util.Set<T> create()
        Creates a new HashSet instance.
        Returns:
        A new HashSet instance.
      • toList

        public static <T> java.util.List<T> toList​(java.util.Set<T> set)
        Converts a Set into a List.
        Type Parameters:
        T - The type of elements in the Set.
        Parameters:
        set - The Set to convert.
        Returns:
        A List containing all elements in the Set.
      • toArray

        public static <T> T[] toArray​(java.util.Set<T> set)
        Converts a Set into a List.
        Type Parameters:
        T - The type of elements in the Set.
        Parameters:
        set - The Set to convert.
        Returns:
        A List containing all elements in the Set.
      • first

        public static <T> T first​(java.util.Set<T> set)
        Returns the first element in the Set, or null if the Set is empty.
        Type Parameters:
        T - The type of elements in the Set.
        Parameters:
        set - The Set to retrieve the first element from.
        Returns:
        The first element in the Set, or null if the Set is empty.
      • from

        public static <T> java.util.Set<T> from​(java.lang.Iterable<T> entries)
        Creates a Set from an Iterable.
        Type Parameters:
        T - The type of elements in the Iterable.
        Parameters:
        entries - The Iterable of entries to add to the Set.
        Returns:
        A Set containing all elements in the Iterable.