java.lang.Object | +--org.apache.commons.collections.SetUtils
static Set | An empty unmodifiable set. |
static SortedSet | An empty unmodifiable sorted set. |
SetUtils() SetUtils should not normally be instantiated. |
static int | hashCodeForSet(final Collection set) Generates a hash code using the algorithm specified in java.util.Set#hashCode(). |
static boolean | isEqualSet(final Collection set1, final Collection set2) Tests two sets for equality as per the equals() contract in java.util.Set#equals(java.lang.Object). |
static Set | orderedSet(Set set) Returns a set that maintains the order of elements that are added backed by the given set. |
static Set | predicatedSet(Set set, Predicate predicate) Returns a predicated set backed by the given set. |
static SortedSet | predicatedSortedSet(SortedSet set, Predicate predicate) Returns a predicated sorted set backed by the given sorted set. |
static Set | synchronizedSet(Set set) Returns a synchronized set backed by the given set. |
static SortedSet | synchronizedSortedSet(SortedSet set) Returns a synchronized sorted set backed by the given sorted set. |
static Set | transformedSet(Set set, Transformer transformer) Returns a transformed set backed by the given set. |
static SortedSet | transformedSortedSet(SortedSet set, Transformer transformer) Returns a transformed sorted set backed by the given set. |
static Set | typedSet(Set set, Class type) Returns a typed set backed by the given set. |
static SortedSet | typedSortedSet(SortedSet set, Class type) Returns a typed sorted set backed by the given set. |
static Set | unmodifiableSet(Set set) Returns an unmodifiable set backed by the given set. |
static SortedSet | unmodifiableSortedSet(SortedSet set) Returns an unmodifiable sorted set backed by the given sorted set. |
public static final Set EMPTY_SET
public static final SortedSet EMPTY_SORTED_SET
public SetUtils()
SetUtils
should not normally be instantiated.
public static int hashCodeForSet(final Collection set)
Set
when you cannot
extend AbstractSet. The method takes Collection instances to enable other
collection types to use the Set implementation algorithm.
java.util.Set.hashCode()
public static boolean isEqualSet(final Collection set1, final Collection set2)
equals()
contract
in java.util.Set.equals(java.lang.Object).
This method is useful for implementing Set
when you cannot
extend AbstractSet. The method takes Collection instances to enable other
collection types to use the Set implementation algorithm.
The relevant text (slightly paraphrased as this is a static method) is:
Two sets are considered equal if they have the same size, and every member of the first set is contained in the second. This ensures that the equals method works properly across different implementations of the Set interface. This implementation first checks if the two sets are the same object: if so it returns true. Then, it checks if the two sets are identical in size; if not, it returns false. If so, it returns a.containsAll((Collection) b).
java.util.Set
public static Set orderedSet(Set set)
- if the Set is nullpublic static Set predicatedSet(Set set, Predicate predicate)
- if the Set or Predicate is nullpublic static SortedSet predicatedSortedSet(SortedSet set, Predicate predicate)
- if the Set or Predicate is nullpublic static Set synchronizedSet(Set set)
Set s = SetUtils.synchronizedSet(mySet); synchronized (s) { Iterator i = s.iterator(); while (i.hasNext()) { process (i.next()); } }This method uses the implementation in the decorators subpackage.
- if the set is nullpublic static SortedSet synchronizedSortedSet(SortedSet set)
Set s = SetUtils.synchronizedSet(mySet); synchronized (s) { Iterator i = s.iterator(); while (i.hasNext()) { process (i.next()); } }This method uses the implementation in the decorators subpackage.
- if the set is nullpublic static Set transformedSet(Set set, Transformer transformer)
- if the Set or Transformer is nullpublic static SortedSet transformedSortedSet(SortedSet set, Transformer transformer)
- if the Set or Transformer is nullpublic static Set typedSet(Set set, Class type)
public static SortedSet typedSortedSet(SortedSet set, Class type)
public static Set unmodifiableSet(Set set)
- if the set is nullpublic static SortedSet unmodifiableSortedSet(SortedSet set)
- if the set is null