org.apache.commons.collections
Class SetUtils

java.lang.Object
  |
  +--org.apache.commons.collections.SetUtils

public class SetUtils
extends java.lang.Object

Provides static utility methods and decorators for Set and SortedSet instances.

Since:
2.1
Version:
$Id: SetUtils.java,v 1.7.2.1 2004/05/22 12:14:02 scolebourne Exp $
Author:
Paul Jack, Stephen Colebourne

Method Summary
static java.util.Set predicatedSet(java.util.Set set, Predicate predicate)
          Returns a predicated set backed by the given set.
static java.util.SortedSet predicatedSortedSet(java.util.SortedSet set, Predicate predicate)
          Returns a predicated sorted set backed by the given sorted set.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

predicatedSet

public static java.util.Set predicatedSet(java.util.Set set,
                                          Predicate predicate)
Returns a predicated set backed by the given set. Only objects that pass the test in the given predicate can be added to the set. It is important not to use the original set after invoking this method, as it is a backdoor for adding unvalidated objects.

Parameters:
set - the set to predicate, must not be null
predicate - the predicate for the set, must not be null
Returns:
a predicated set backed by the given set
Throws:
java.lang.IllegalArgumentException - if the Set or Predicate is null

predicatedSortedSet

public static java.util.SortedSet predicatedSortedSet(java.util.SortedSet set,
                                                      Predicate predicate)
Returns a predicated sorted set backed by the given sorted set. Only objects that pass the test in the given predicate can be added to the sorted set. It is important not to use the original sorted set after invoking this method, as it is a backdoor for adding unvalidated objects.

Parameters:
set - the sorted set to predicate, must not be null
predicate - the predicate for the sorted set, must not be null
Returns:
a predicated sorted set backed by the given sorted set
Throws:
java.lang.IllegalArgumentException - if the Set or Predicate is null


Copyright © 2001-2004 The Apache Software Foundation. All Rights Reserved.