Class SetUtil

java.lang.Object
com.onenetwork.platform.tools.collections.SetUtil

public class SetUtil
extends java.lang.Object
Utilities for Set manipulation.
  • Method Summary

    Modifier and Type Method Description
    static <T> java.util.Set<T> create​(T element)
    Convenience method for creating a new, mutable Set containing a single element.
    static <T> java.util.Set<T> create​(T... elements)
    Convenience method for creating a new, mutable Set given homogeneous varargs.
    static <T> boolean isProperSuperset​(java.util.Set<T> a, java.util.Set<T> b)
    Returns true iff set "a" is a proper superset of set "b", i.e.

    Methods inherited from class java.lang.Object

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

    • create

      public static <T> java.util.Set<T> create​(T element)
      Convenience method for creating a new, mutable Set containing a single element.
      Type Parameters:
      T - element type
      Parameters:
      element - element to go into the Set
      Returns:
      new Set containing the given element
    • create

      @SafeVarargs public static <T> java.util.Set<T> create​(T... elements)
      Convenience method for creating a new, mutable Set given homogeneous varargs.

      Sample usage: Set<String> strings = SetUtil.newSet("A", "B", "C");

      Type Parameters:
      T - element type
      Parameters:
      elements - elements to go into the Set
      Returns:
      new Set containing all given elements
    • isProperSuperset

      public static <T> boolean isProperSuperset​(java.util.Set<T> a, java.util.Set<T> b)
      Returns true iff set "a" is a proper superset of set "b", i.e. it contains all values of "b" and at least one additional value.