More IllegalArgument checks to decorators.

PR:
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130792 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
pjack 2002-08-17 21:10:46 +00:00
parent db484419cb
commit a24ad64d19
5 changed files with 57 additions and 18 deletions

View File

@ -1,7 +1,7 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/BagUtils.java,v 1.3 2002/08/13 00:49:59 pjack Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/BagUtils.java,v 1.4 2002/08/17 21:10:46 pjack Exp $
* $Revision: 1.3 $ * $Revision: 1.4 $
* $Date: 2002/08/13 00:49:59 $ * $Date: 2002/08/17 21:10:46 $
* *
* ==================================================================== * ====================================================================
* *
@ -71,7 +71,7 @@ import java.util.Set;
* and {@link SortedBag} instances.<P> * and {@link SortedBag} instances.<P>
* *
* @author Paul Jack * @author Paul Jack
* @version $Id: BagUtils.java,v 1.3 2002/08/13 00:49:59 pjack Exp $ * @version $Id: BagUtils.java,v 1.4 2002/08/17 21:10:46 pjack Exp $
* @since 2.1 * @since 2.1
*/ */
public class BagUtils { public class BagUtils {
@ -182,6 +182,9 @@ public class BagUtils {
public BoundedBag(Bag bag, int maxSize) { public BoundedBag(Bag bag, int maxSize) {
super(bag); super(bag);
if (maxSize < 0) {
throw new IllegalArgumentException("maxSize must be nonnegative.");
}
this.maxSize = maxSize; this.maxSize = maxSize;
} }

View File

@ -1,7 +1,7 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/CollectionUtils.java,v 1.12 2002/08/17 11:38:35 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.13 2002/08/17 21:10:46 pjack Exp $
* $Revision: 1.12 $ * $Revision: 1.13 $
* $Date: 2002/08/17 11:38:35 $ * $Date: 2002/08/17 21:10:46 $
* *
* ==================================================================== * ====================================================================
* *
@ -81,7 +81,7 @@ import org.apache.commons.collections.iterators.EnumerationIterator;
* @author Rodney Waldhoff * @author Rodney Waldhoff
* *
* @since 1.0 * @since 1.0
* @version $Id: CollectionUtils.java,v 1.12 2002/08/17 11:38:35 scolebourne Exp $ * @version $Id: CollectionUtils.java,v 1.13 2002/08/17 21:10:46 pjack Exp $
*/ */
public class CollectionUtils { public class CollectionUtils {
@ -753,6 +753,9 @@ public class CollectionUtils {
public BoundedCollection(Collection c, int maxSize) { public BoundedCollection(Collection c, int maxSize) {
super(c); super(c);
if (maxSize < 0) {
throw new IllegalArgumentException("maxSize must be nonnegative.");
}
this.maxSize = maxSize; this.maxSize = maxSize;
} }

View File

@ -1,7 +1,7 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/ListUtils.java,v 1.8 2002/08/15 20:09:37 pjack Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/ListUtils.java,v 1.9 2002/08/17 21:10:46 pjack Exp $
* $Revision: 1.8 $ * $Revision: 1.9 $
* $Date: 2002/08/15 20:09:37 $ * $Date: 2002/08/17 21:10:46 $
* *
* ==================================================================== * ====================================================================
* *
@ -364,6 +364,9 @@ public class ListUtils
public BoundedList(List list, int maxSize) { public BoundedList(List list, int maxSize) {
super(list); super(list);
if (maxSize < 0) {
throw new IllegalArgumentException("maxSize must be nonnegative.");
}
this.maxSize = maxSize; this.maxSize = maxSize;
} }
@ -444,6 +447,9 @@ public class ListUtils
public LazyList(List list, Factory factory) { public LazyList(List list, Factory factory) {
super(list); super(list);
if (factory == null) {
throw new IllegalArgumentException("factory may not be null");
}
this.factory = factory; this.factory = factory;
} }

View File

@ -1,7 +1,7 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/MapUtils.java,v 1.9 2002/08/15 20:09:37 pjack Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/MapUtils.java,v 1.10 2002/08/17 21:10:46 pjack Exp $
* $Revision: 1.9 $ * $Revision: 1.10 $
* $Date: 2002/08/15 20:09:37 $ * $Date: 2002/08/17 21:10:46 $
* *
* ==================================================================== * ====================================================================
* *
@ -736,6 +736,15 @@ public class MapUtils {
public PredicatedMap(Map map, Predicate keyPred, Predicate valuePred) { public PredicatedMap(Map map, Predicate keyPred, Predicate valuePred) {
super(map); super(map);
if (map == null) {
throw new IllegalArgumentException("map may not be null.");
}
if (keyPred == null) {
throw new IllegalArgumentException("keyPred may not be null.");
}
if (valuePred == null) {
throw new IllegalArgumentException("valuePred may not be null.");
}
this.keyPredicate = keyPred; this.keyPredicate = keyPred;
this.valuePredicate = valuePred; this.valuePredicate = valuePred;
Iterator iter = map.entrySet().iterator(); Iterator iter = map.entrySet().iterator();
@ -856,6 +865,12 @@ public class MapUtils {
public BoundedMap(Map map, int maxSize) { public BoundedMap(Map map, int maxSize) {
super(map); super(map);
if (map == null) {
throw new IllegalArgumentException("map may not be null.");
}
if (maxSize < 0) {
throw new IllegalArgumentException("maxSize must be nonnegative.");
}
this.maxSize = maxSize; this.maxSize = maxSize;
} }
@ -886,6 +901,9 @@ public class MapUtils {
public FixedSizeMap(Map map) { public FixedSizeMap(Map map) {
super(map); super(map);
if (map == null) {
throw new IllegalArgumentException("map may not be null.");
}
} }
@ -916,6 +934,12 @@ public class MapUtils {
public LazyMap(Map map, Factory factory) { public LazyMap(Map map, Factory factory) {
super(map); super(map);
if (map == null) {
throw new IllegalArgumentException("map may not be null.");
}
if (factory == null) {
throw new IllegalArgumentException("factory may not be null.");
}
this.factory = factory; this.factory = factory;
} }

View File

@ -1,7 +1,7 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/SetUtils.java,v 1.3 2002/08/13 00:49:59 pjack Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/SetUtils.java,v 1.4 2002/08/17 21:10:46 pjack Exp $
* $Revision: 1.3 $ * $Revision: 1.4 $
* $Date: 2002/08/13 00:49:59 $ * $Date: 2002/08/17 21:10:46 $
* *
* ==================================================================== * ====================================================================
* *
@ -73,7 +73,7 @@ import java.util.SortedSet;
* and {@link SortedSet} instances. * and {@link SortedSet} instances.
* *
* @author Paul Jack * @author Paul Jack
* @version $Id: SetUtils.java,v 1.3 2002/08/13 00:49:59 pjack Exp $ * @version $Id: SetUtils.java,v 1.4 2002/08/17 21:10:46 pjack Exp $
* @since 2.1 * @since 2.1
*/ */
public class SetUtils { public class SetUtils {
@ -103,6 +103,9 @@ public class SetUtils {
public BoundedSet(Set set, int maxSize) { public BoundedSet(Set set, int maxSize) {
super(set); super(set);
if (maxSize < 0) {
throw new IllegalArgumentException("maxSize must be nonnegative.");
}
this.maxSize = maxSize; this.maxSize = maxSize;
} }