Add transformed decorators to static utilities
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131073 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
611120275c
commit
6e9f2b17d2
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/BagUtils.java,v 1.10 2003/05/09 18:41:34 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/BagUtils.java,v 1.11 2003/05/11 13:29:16 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -61,6 +61,8 @@ import org.apache.commons.collections.decorators.PredicatedBag;
|
|||
import org.apache.commons.collections.decorators.PredicatedSortedBag;
|
||||
import org.apache.commons.collections.decorators.SynchronizedBag;
|
||||
import org.apache.commons.collections.decorators.SynchronizedSortedBag;
|
||||
import org.apache.commons.collections.decorators.TransformedBag;
|
||||
import org.apache.commons.collections.decorators.TransformedSortedBag;
|
||||
import org.apache.commons.collections.decorators.TypedBag;
|
||||
import org.apache.commons.collections.decorators.TypedSortedBag;
|
||||
import org.apache.commons.collections.decorators.UnmodifiableBag;
|
||||
|
@ -71,7 +73,7 @@ import org.apache.commons.collections.decorators.UnmodifiableSortedBag;
|
|||
* and {@link SortedBag} instances.
|
||||
*
|
||||
* @since Commons Collections 2.1
|
||||
* @version $Revision: 1.10 $ $Date: 2003/05/09 18:41:34 $
|
||||
* @version $Revision: 1.11 $ $Date: 2003/05/11 13:29:16 $
|
||||
*
|
||||
* @author Paul Jack
|
||||
* @author Stephen Colebourne
|
||||
|
@ -155,7 +157,7 @@ public class BagUtils {
|
|||
public static Bag predicatedBag(Bag bag, Predicate predicate) {
|
||||
return PredicatedBag.decorate(bag, predicate);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a typed bag backed by the given bag.
|
||||
* <p>
|
||||
|
@ -169,6 +171,22 @@ public class BagUtils {
|
|||
return TypedBag.decorate(bag, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a transformed bag backed by the given bag.
|
||||
* <p>
|
||||
* Each object is passed through the transformer as it is added to the
|
||||
* Bag. It is important not to use the original bag after invoking this
|
||||
* method, as it is a backdoor for adding untransformed objects.
|
||||
*
|
||||
* @param bag the bag to predicate, must not be null
|
||||
* @param transformer the transformer for the bag, must not be null
|
||||
* @return a transformed bag backed by the given bag
|
||||
* @throws IllegalArgumentException if the Bag or Transformer is null
|
||||
*/
|
||||
public static Bag transformedBag(Bag bag, Transformer transformer) {
|
||||
return TransformedBag.decorate(bag, transformer);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Returns a synchronized (thread-safe) sorted bag backed by the given
|
||||
|
@ -242,5 +260,21 @@ public class BagUtils {
|
|||
public static SortedBag typedSortedBag(SortedBag bag, Class type) {
|
||||
return TypedSortedBag.decorate(bag, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a transformed sorted bag backed by the given bag.
|
||||
* <p>
|
||||
* Each object is passed through the transformer as it is added to the
|
||||
* Bag. It is important not to use the original bag after invoking this
|
||||
* method, as it is a backdoor for adding untransformed objects.
|
||||
*
|
||||
* @param bag the bag to predicate, must not be null
|
||||
* @param transformer the transformer for the bag, must not be null
|
||||
* @return a transformed bag backed by the given bag
|
||||
* @throws IllegalArgumentException if the Bag or Transformer is null
|
||||
*/
|
||||
public static SortedBag transformedSortedBag(SortedBag bag, Transformer transformer) {
|
||||
return TransformedSortedBag.decorate(bag, transformer);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/BufferUtils.java,v 1.11 2003/05/09 18:41:34 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/BufferUtils.java,v 1.12 2003/05/11 13:29:16 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -60,6 +60,7 @@ package org.apache.commons.collections;
|
|||
import org.apache.commons.collections.decorators.BlockingBuffer;
|
||||
import org.apache.commons.collections.decorators.PredicatedBuffer;
|
||||
import org.apache.commons.collections.decorators.SynchronizedBuffer;
|
||||
import org.apache.commons.collections.decorators.TransformedBuffer;
|
||||
import org.apache.commons.collections.decorators.TypedBuffer;
|
||||
import org.apache.commons.collections.decorators.UnmodifiableBuffer;
|
||||
|
||||
|
@ -67,7 +68,7 @@ import org.apache.commons.collections.decorators.UnmodifiableBuffer;
|
|||
* Contains static utility methods for operating on {@link Buffer} objects.
|
||||
*
|
||||
* @since Commons Collections 2.1
|
||||
* @version $Revision: 1.11 $ $Date: 2003/05/09 18:41:34 $
|
||||
* @version $Revision: 1.12 $ $Date: 2003/05/11 13:29:16 $
|
||||
*
|
||||
* @author Paul Jack
|
||||
* @author Stephen Colebourne
|
||||
|
@ -166,4 +167,20 @@ public class BufferUtils {
|
|||
return TypedBuffer.decorate(buffer, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a transformed buffer backed by the given buffer.
|
||||
* <p>
|
||||
* Each object is passed through the transformer as it is added to the
|
||||
* Buffer. It is important not to use the original buffer after invoking this
|
||||
* method, as it is a backdoor for adding untransformed objects.
|
||||
*
|
||||
* @param buffer the buffer to predicate, must not be null
|
||||
* @param transformer the transformer for the buffer, must not be null
|
||||
* @return a transformed buffer backed by the given buffer
|
||||
* @throws IllegalArgumentException if the Buffer or Transformer is null
|
||||
*/
|
||||
public static Buffer transformedBuffer(Buffer buffer, Transformer transformer) {
|
||||
return TransformedBuffer.decorate(buffer, transformer);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/CollectionUtils.java,v 1.30 2003/05/09 18:41:34 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/CollectionUtils.java,v 1.31 2003/05/11 13:29:16 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -71,6 +71,7 @@ import java.util.NoSuchElementException;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections.decorators.PredicatedCollection;
|
||||
import org.apache.commons.collections.decorators.TransformedCollection;
|
||||
import org.apache.commons.collections.decorators.TypedCollection;
|
||||
import org.apache.commons.collections.decorators.UnmodifiableBoundedCollection;
|
||||
import org.apache.commons.collections.iterators.ArrayIterator;
|
||||
|
@ -80,7 +81,7 @@ import org.apache.commons.collections.iterators.EnumerationIterator;
|
|||
* A set of {@link Collection} related utility methods.
|
||||
*
|
||||
* @since Commons Collections 1.0
|
||||
* @version $Revision: 1.30 $ $Date: 2003/05/09 18:41:34 $
|
||||
* @version $Revision: 1.31 $ $Date: 2003/05/11 13:29:16 $
|
||||
*
|
||||
* @author Rodney Waldhoff
|
||||
* @author Paul Jack
|
||||
|
@ -939,4 +940,20 @@ public class CollectionUtils {
|
|||
return TypedCollection.decorate(collection, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a transformed bag backed by the given collection.
|
||||
* <p>
|
||||
* Each object is passed through the transformer as it is added to the
|
||||
* Collection. It is important not to use the original collection after invoking this
|
||||
* method, as it is a backdoor for adding untransformed objects.
|
||||
*
|
||||
* @param collection the collection to predicate, must not be null
|
||||
* @param transformer the transformer for the collection, must not be null
|
||||
* @return a transformed collection backed by the given collection
|
||||
* @throws IllegalArgumentException if the Collection or Transformer is null
|
||||
*/
|
||||
public static Collection transformedCollection(Collection collection, Transformer transformer) {
|
||||
return TransformedCollection.decorate(collection, transformer);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/ListUtils.java,v 1.17 2003/05/09 18:41:34 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/ListUtils.java,v 1.18 2003/05/11 13:29:16 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -66,6 +66,7 @@ import java.util.List;
|
|||
import org.apache.commons.collections.decorators.FixedSizeList;
|
||||
import org.apache.commons.collections.decorators.LazyList;
|
||||
import org.apache.commons.collections.decorators.PredicatedList;
|
||||
import org.apache.commons.collections.decorators.TransformedList;
|
||||
import org.apache.commons.collections.decorators.TypedList;
|
||||
|
||||
/**
|
||||
|
@ -73,7 +74,7 @@ import org.apache.commons.collections.decorators.TypedList;
|
|||
* instances.
|
||||
*
|
||||
* @since Commons Collections 1.0
|
||||
* @version $Revision: 1.17 $ $Date: 2003/05/09 18:41:34 $
|
||||
* @version $Revision: 1.18 $ $Date: 2003/05/11 13:29:16 $
|
||||
*
|
||||
* @author <a href="mailto:fede@apache.org">Federico Barbieri</a>
|
||||
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
|
||||
|
@ -325,6 +326,22 @@ public class ListUtils {
|
|||
return TypedList.decorate(list, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a transformed list backed by the given list.
|
||||
* <p>
|
||||
* Each object is passed through the transformer as it is added to the
|
||||
* List. It is important not to use the original list after invoking this
|
||||
* method, as it is a backdoor for adding untransformed objects.
|
||||
*
|
||||
* @param list the list to predicate, must not be null
|
||||
* @param transformer the transformer for the list, must not be null
|
||||
* @return a transformed list backed by the given list
|
||||
* @throws IllegalArgumentException if the List or Transformer is null
|
||||
*/
|
||||
public static List transformedList(List list, Transformer transformer) {
|
||||
return TransformedList.decorate(list, transformer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a "lazy" list whose elements will be created on demand.<P>
|
||||
* <p>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/SetUtils.java,v 1.13 2003/05/09 18:41:34 scolebourne Exp $
|
||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/SetUtils.java,v 1.14 2003/05/11 13:29:16 scolebourne Exp $
|
||||
* ====================================================================
|
||||
*
|
||||
* The Apache Software License, Version 1.1
|
||||
|
@ -66,6 +66,8 @@ import java.util.TreeSet;
|
|||
|
||||
import org.apache.commons.collections.decorators.PredicatedSet;
|
||||
import org.apache.commons.collections.decorators.PredicatedSortedSet;
|
||||
import org.apache.commons.collections.decorators.TransformedSet;
|
||||
import org.apache.commons.collections.decorators.TransformedSortedSet;
|
||||
import org.apache.commons.collections.decorators.TypedSet;
|
||||
import org.apache.commons.collections.decorators.TypedSortedSet;
|
||||
|
||||
|
@ -74,7 +76,7 @@ import org.apache.commons.collections.decorators.TypedSortedSet;
|
|||
* and {@link SortedSet} instances.
|
||||
*
|
||||
* @since Commons Collections 2.1
|
||||
* @version $Revision: 1.13 $ $Date: 2003/05/09 18:41:34 $
|
||||
* @version $Revision: 1.14 $ $Date: 2003/05/11 13:29:16 $
|
||||
*
|
||||
* @author Paul Jack
|
||||
* @author Stephen Colebourne
|
||||
|
@ -238,6 +240,22 @@ public class SetUtils {
|
|||
return TypedSet.decorate(set, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a transformed set backed by the given set.
|
||||
* <p>
|
||||
* Each object is passed through the transformer as it is added to the
|
||||
* Set. It is important not to use the original set after invoking this
|
||||
* method, as it is a backdoor for adding untransformed objects.
|
||||
*
|
||||
* @param set the set to predicate, must not be null
|
||||
* @param transformer the transformer for the set, must not be null
|
||||
* @return a transformed set backed by the given set
|
||||
* @throws IllegalArgumentException if the Set or Transformer is null
|
||||
*/
|
||||
public static Set transformedSet(Set set, Transformer transformer) {
|
||||
return TransformedSet.decorate(set, transformer);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Returns a synchronized sorted set backed by the given sorted set.
|
||||
|
@ -307,4 +325,20 @@ public class SetUtils {
|
|||
return TypedSortedSet.decorate(set, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a transformed sorted set backed by the given set.
|
||||
* <p>
|
||||
* Each object is passed through the transformer as it is added to the
|
||||
* Set. It is important not to use the original set after invoking this
|
||||
* method, as it is a backdoor for adding untransformed objects.
|
||||
*
|
||||
* @param set the set to predicate, must not be null
|
||||
* @param transformer the transformer for the set, must not be null
|
||||
* @return a transformed set backed by the given set
|
||||
* @throws IllegalArgumentException if the Set or Transformer is null
|
||||
*/
|
||||
public static SortedSet transformedSortedSet(SortedSet set, Transformer transformer) {
|
||||
return TransformedSortedSet.decorate(set, transformer);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue