org.apache.commons.collections

Class SetUtils


public class SetUtils
extends java.lang.Object

Provides static utility methods and decorators for Set and SortedSet instances.
Version:
$Id: SetUtils.java,v 1.7.2.1 2004/05/22 12:14:02 scolebourne Exp $
Authors:
Paul Jack
Stephen Colebourne
Since:
2.1

Method Summary

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.

Method Details

predicatedSet

public static Set predicatedSet(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

predicatedSortedSet

public static SortedSet predicatedSortedSet(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

Copyright © 2001-2004 Apache Software Foundation. Documenation generated ${TODAY}.