From 5bd1ed25de6233520975d9a2aad855bf09d90022 Mon Sep 17 00:00:00 2001 From: Stephen Colebourne Date: Sat, 13 Mar 2004 17:17:03 +0000 Subject: [PATCH] Add getters to functor classes bug 27515 git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131605 13f79535-47bb-0310-9956-ffa450edef68 --- RELEASE-NOTES.html | 7 ++-- .../collections/functors/AllPredicate.java | 13 ++++++-- .../collections/functors/AndPredicate.java | 22 +++++++++++-- .../collections/functors/AnyPredicate.java | 13 ++++++-- .../collections/functors/ChainedClosure.java | 13 ++++++-- .../functors/ChainedTransformer.java | 13 ++++++-- .../functors/ClosureTransformer.java | 13 ++++++-- .../collections/functors/ConstantFactory.java | 13 ++++++-- .../functors/ConstantTransformer.java | 13 ++++++-- .../collections/functors/EqualPredicate.java | 13 ++++++-- .../functors/FactoryTransformer.java | 13 ++++++-- .../collections/functors/ForClosure.java | 22 +++++++++++-- .../functors/IdentityPredicate.java | 13 ++++++-- .../collections/functors/IfClosure.java | 31 +++++++++++++++-- .../functors/InstanceofPredicate.java | 13 ++++++-- .../collections/functors/MapTransformer.java | 13 ++++++-- .../collections/functors/NonePredicate.java | 13 ++++++-- .../collections/functors/NotPredicate.java | 13 ++++++-- .../functors/NullIsExceptionPredicate.java | 13 ++++++-- .../functors/NullIsFalsePredicate.java | 13 ++++++-- .../functors/NullIsTruePredicate.java | 13 ++++++-- .../collections/functors/OnePredicate.java | 13 ++++++-- .../collections/functors/OrPredicate.java | 22 +++++++++++-- .../functors/PredicateTransformer.java | 13 ++++++-- .../collections/functors/SwitchClosure.java | 31 +++++++++++++++-- .../functors/SwitchTransformer.java | 33 +++++++++++++++++-- .../functors/TransformerClosure.java | 13 ++++++-- .../functors/TransformerPredicate.java | 13 ++++++-- .../collections/functors/WhileClosure.java | 32 ++++++++++++++++-- 29 files changed, 412 insertions(+), 61 deletions(-) diff --git a/RELEASE-NOTES.html b/RELEASE-NOTES.html index 308f63e15..da5d396b9 100644 --- a/RELEASE-NOTES.html +++ b/RELEASE-NOTES.html @@ -25,22 +25,23 @@ No interface changes, or deprecations have occurred.

NEW CLASSES

ENHANCEMENTS

BUG FIXES

JAVADOC

diff --git a/src/java/org/apache/commons/collections/functors/AllPredicate.java b/src/java/org/apache/commons/collections/functors/AllPredicate.java index 17ab7ee88..db33f68ee 100644 --- a/src/java/org/apache/commons/collections/functors/AllPredicate.java +++ b/src/java/org/apache/commons/collections/functors/AllPredicate.java @@ -24,7 +24,7 @@ import org.apache.commons.collections.Predicate; * Predicate implementation that returns true if all the predicates return true. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -87,5 +87,14 @@ public final class AllPredicate implements Predicate, Serializable { } return true; } - + + /** + * Gets the predicates, do not modify the array. + * @return the predicates + * @since Commons Collections 3.1 + */ + public Predicate[] getPredicates() { + return iPredicates; + } + } diff --git a/src/java/org/apache/commons/collections/functors/AndPredicate.java b/src/java/org/apache/commons/collections/functors/AndPredicate.java index 11cbd7aa2..80b55e73b 100644 --- a/src/java/org/apache/commons/collections/functors/AndPredicate.java +++ b/src/java/org/apache/commons/collections/functors/AndPredicate.java @@ -23,7 +23,7 @@ import org.apache.commons.collections.Predicate; * Predicate implementation that returns true if both the predicates return true. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -71,5 +71,23 @@ public final class AndPredicate implements Predicate, Serializable { public boolean evaluate(Object object) { return (iPredicate1.evaluate(object) && iPredicate2.evaluate(object)); } - + + /** + * Gets the first predicate. + * @return the predicate + * @since Commons Collections 3.1 + */ + public Predicate getPredicate1() { + return iPredicate1; + } + + /** + * Gets the second predicate. + * @return the predicate + * @since Commons Collections 3.1 + */ + public Predicate getPredicate2() { + return iPredicate2; + } + } diff --git a/src/java/org/apache/commons/collections/functors/AnyPredicate.java b/src/java/org/apache/commons/collections/functors/AnyPredicate.java index 96d0e98ef..80aad90da 100644 --- a/src/java/org/apache/commons/collections/functors/AnyPredicate.java +++ b/src/java/org/apache/commons/collections/functors/AnyPredicate.java @@ -24,7 +24,7 @@ import org.apache.commons.collections.Predicate; * Predicate implementation that returns true if any of the predicates return true. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -87,5 +87,14 @@ public final class AnyPredicate implements Predicate, Serializable { } return false; } - + + /** + * Gets the predicates, do not modify the array. + * @return the predicates + * @since Commons Collections 3.1 + */ + public Predicate[] getPredicates() { + return iPredicates; + } + } diff --git a/src/java/org/apache/commons/collections/functors/ChainedClosure.java b/src/java/org/apache/commons/collections/functors/ChainedClosure.java index a84873093..bb1fa7e91 100644 --- a/src/java/org/apache/commons/collections/functors/ChainedClosure.java +++ b/src/java/org/apache/commons/collections/functors/ChainedClosure.java @@ -25,7 +25,7 @@ import org.apache.commons.collections.Closure; * Closure implementation that chains the specified closures together. * * @since Commons Collections 3.0 - * @version $Revision: 1.4 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.5 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -118,5 +118,14 @@ public class ChainedClosure implements Closure, Serializable { iClosures[i].execute(input); } } - + + /** + * Gets the closures, do not modify the array. + * @return the closures + * @since Commons Collections 3.1 + */ + public Closure[] getClosures() { + return iClosures; + } + } diff --git a/src/java/org/apache/commons/collections/functors/ChainedTransformer.java b/src/java/org/apache/commons/collections/functors/ChainedTransformer.java index 400d61687..30859be5e 100644 --- a/src/java/org/apache/commons/collections/functors/ChainedTransformer.java +++ b/src/java/org/apache/commons/collections/functors/ChainedTransformer.java @@ -25,7 +25,7 @@ import org.apache.commons.collections.Transformer; * Transformer implementation that chains the specified closures together. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.6 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -119,5 +119,14 @@ public class ChainedTransformer implements Transformer, Serializable { } return object; } - + + /** + * Gets the transformers, do not modify the array. + * @return the transformers + * @since Commons Collections 3.1 + */ + public Transformer[] getTransformers() { + return iTransformers; + } + } diff --git a/src/java/org/apache/commons/collections/functors/ClosureTransformer.java b/src/java/org/apache/commons/collections/functors/ClosureTransformer.java index f516ede24..b2b7cb858 100644 --- a/src/java/org/apache/commons/collections/functors/ClosureTransformer.java +++ b/src/java/org/apache/commons/collections/functors/ClosureTransformer.java @@ -25,7 +25,7 @@ import org.apache.commons.collections.Transformer; * and then returns the input. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -69,5 +69,14 @@ public class ClosureTransformer implements Transformer, Serializable { iClosure.execute(input); return input; } - + + /** + * Gets the closure. + * @return the closure + * @since Commons Collections 3.1 + */ + public Closure getClosure() { + return iClosure; + } + } diff --git a/src/java/org/apache/commons/collections/functors/ConstantFactory.java b/src/java/org/apache/commons/collections/functors/ConstantFactory.java index ed279a14a..c7d8a98b4 100644 --- a/src/java/org/apache/commons/collections/functors/ConstantFactory.java +++ b/src/java/org/apache/commons/collections/functors/ConstantFactory.java @@ -27,7 +27,7 @@ import org.apache.commons.collections.Factory; * use the prototype factory. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -72,5 +72,14 @@ public class ConstantFactory implements Factory, Serializable { public Object create() { return iConstant; } - + + /** + * Gets the constant. + * @return the constant + * @since Commons Collections 3.1 + */ + public Object getConstant() { + return iConstant; + } + } diff --git a/src/java/org/apache/commons/collections/functors/ConstantTransformer.java b/src/java/org/apache/commons/collections/functors/ConstantTransformer.java index a205e73e7..5f28e65a1 100644 --- a/src/java/org/apache/commons/collections/functors/ConstantTransformer.java +++ b/src/java/org/apache/commons/collections/functors/ConstantTransformer.java @@ -27,7 +27,7 @@ import org.apache.commons.collections.Transformer; * use the prototype factory. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -72,5 +72,14 @@ public class ConstantTransformer implements Transformer, Serializable { public Object transform(Object input) { return iConstant; } - + + /** + * Gets the constant. + * @return the constant + * @since Commons Collections 3.1 + */ + public Object getConstant() { + return iConstant; + } + } diff --git a/src/java/org/apache/commons/collections/functors/EqualPredicate.java b/src/java/org/apache/commons/collections/functors/EqualPredicate.java index 6a02099ea..e34e43487 100644 --- a/src/java/org/apache/commons/collections/functors/EqualPredicate.java +++ b/src/java/org/apache/commons/collections/functors/EqualPredicate.java @@ -24,7 +24,7 @@ import org.apache.commons.collections.Predicate; * as the one stored in this predicate by equals. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -67,5 +67,14 @@ public final class EqualPredicate implements Predicate, Serializable { public boolean evaluate(Object object) { return (iValue.equals(object)); } - + + /** + * Gets the value. + * @return the value + * @since Commons Collections 3.1 + */ + public Object getValue() { + return iValue; + } + } diff --git a/src/java/org/apache/commons/collections/functors/FactoryTransformer.java b/src/java/org/apache/commons/collections/functors/FactoryTransformer.java index c72cecd0e..8eaf0340e 100644 --- a/src/java/org/apache/commons/collections/functors/FactoryTransformer.java +++ b/src/java/org/apache/commons/collections/functors/FactoryTransformer.java @@ -24,7 +24,7 @@ import org.apache.commons.collections.Transformer; * Transformer implementation that calls a Factory and returns the result. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -67,5 +67,14 @@ public class FactoryTransformer implements Transformer, Serializable { public Object transform(Object input) { return iFactory.create(); } - + + /** + * Gets the factory. + * @return the factory + * @since Commons Collections 3.1 + */ + public Factory getFactory() { + return iFactory; + } + } diff --git a/src/java/org/apache/commons/collections/functors/ForClosure.java b/src/java/org/apache/commons/collections/functors/ForClosure.java index d8deecea7..5f7857879 100644 --- a/src/java/org/apache/commons/collections/functors/ForClosure.java +++ b/src/java/org/apache/commons/collections/functors/ForClosure.java @@ -23,7 +23,7 @@ import org.apache.commons.collections.Closure; * Closure implementation that calls another closure n times, like a for loop. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -78,5 +78,23 @@ public class ForClosure implements Closure, Serializable { iClosure.execute(input); } } - + + /** + * Gets the closure. + * @return the closure + * @since Commons Collections 3.1 + */ + public Closure getClosure() { + return iClosure; + } + + /** + * Gets the count. + * @return the count + * @since Commons Collections 3.1 + */ + public int getCount() { + return iCount; + } + } diff --git a/src/java/org/apache/commons/collections/functors/IdentityPredicate.java b/src/java/org/apache/commons/collections/functors/IdentityPredicate.java index f3fce306b..fcd4028cd 100644 --- a/src/java/org/apache/commons/collections/functors/IdentityPredicate.java +++ b/src/java/org/apache/commons/collections/functors/IdentityPredicate.java @@ -24,7 +24,7 @@ import org.apache.commons.collections.Predicate; * as the one stored in this predicate. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -68,5 +68,14 @@ public final class IdentityPredicate implements Predicate, Serializable { public boolean evaluate(Object object) { return (iValue == object); } - + + /** + * Gets the value. + * @return the value + * @since Commons Collections 3.1 + */ + public Object getValue() { + return iValue; + } + } diff --git a/src/java/org/apache/commons/collections/functors/IfClosure.java b/src/java/org/apache/commons/collections/functors/IfClosure.java index b81d466a2..1985ad811 100644 --- a/src/java/org/apache/commons/collections/functors/IfClosure.java +++ b/src/java/org/apache/commons/collections/functors/IfClosure.java @@ -25,7 +25,7 @@ import org.apache.commons.collections.Predicate; * based on a predicate. * * @since Commons Collections 3.0 - * @version $Revision: 1.4 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.5 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -85,5 +85,32 @@ public class IfClosure implements Closure, Serializable { iFalseClosure.execute(input); } } - + + /** + * Gets the predicate. + * @return the predicate + * @since Commons Collections 3.1 + */ + public Predicate getPredicate() { + return iPredicate; + } + + /** + * Gets the closure called when true. + * @return the closure + * @since Commons Collections 3.1 + */ + public Closure getTrueClosure() { + return iTrueClosure; + } + + /** + * Gets the closure called when false. + * @return the closure + * @since Commons Collections 3.1 + */ + public Closure getFalseClosure() { + return iFalseClosure; + } + } diff --git a/src/java/org/apache/commons/collections/functors/InstanceofPredicate.java b/src/java/org/apache/commons/collections/functors/InstanceofPredicate.java index bed99c178..23028d42c 100644 --- a/src/java/org/apache/commons/collections/functors/InstanceofPredicate.java +++ b/src/java/org/apache/commons/collections/functors/InstanceofPredicate.java @@ -24,7 +24,7 @@ import org.apache.commons.collections.Predicate; * the type stored in this predicate. * * @since Commons Collections 3.0 - * @version $Revision: 1.4 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.5 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -67,5 +67,14 @@ public final class InstanceofPredicate implements Predicate, Serializable { public boolean evaluate(Object object) { return (iType.isInstance(object)); } - + + /** + * Gets the type to compare to. + * @return the type + * @since Commons Collections 3.1 + */ + public Class getType() { + return iType; + } + } diff --git a/src/java/org/apache/commons/collections/functors/MapTransformer.java b/src/java/org/apache/commons/collections/functors/MapTransformer.java index 6416c1da3..246d243fb 100644 --- a/src/java/org/apache/commons/collections/functors/MapTransformer.java +++ b/src/java/org/apache/commons/collections/functors/MapTransformer.java @@ -25,7 +25,7 @@ import org.apache.commons.collections.Transformer; * using the input parameter as a key. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.6 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -69,5 +69,14 @@ public final class MapTransformer implements Transformer, Serializable { public Object transform(Object input) { return iMap.get(input); } - + + /** + * Gets the map to lookup in. + * @return the map + * @since Commons Collections 3.1 + */ + public Map getMap() { + return iMap; + } + } diff --git a/src/java/org/apache/commons/collections/functors/NonePredicate.java b/src/java/org/apache/commons/collections/functors/NonePredicate.java index bca4dd6c0..4b91f2e4a 100644 --- a/src/java/org/apache/commons/collections/functors/NonePredicate.java +++ b/src/java/org/apache/commons/collections/functors/NonePredicate.java @@ -24,7 +24,7 @@ import org.apache.commons.collections.Predicate; * Predicate implementation that returns true if none of the predicates return true. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -87,5 +87,14 @@ public final class NonePredicate implements Predicate, Serializable { } return true; } - + + /** + * Gets the predicates, do not modify the array. + * @return the predicates + * @since Commons Collections 3.1 + */ + public Predicate[] getPredicates() { + return iPredicates; + } + } diff --git a/src/java/org/apache/commons/collections/functors/NotPredicate.java b/src/java/org/apache/commons/collections/functors/NotPredicate.java index c315207e8..00a01671e 100644 --- a/src/java/org/apache/commons/collections/functors/NotPredicate.java +++ b/src/java/org/apache/commons/collections/functors/NotPredicate.java @@ -23,7 +23,7 @@ import org.apache.commons.collections.Predicate; * Predicate implementation that returns the opposite of the decorated predicate. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -66,5 +66,14 @@ public final class NotPredicate implements Predicate, Serializable { public boolean evaluate(Object object) { return !(iPredicate.evaluate(object)); } - + + /** + * Gets the predicate. + * @return the predicate + * @since Commons Collections 3.1 + */ + public Predicate getPredicate() { + return iPredicate; + } + } diff --git a/src/java/org/apache/commons/collections/functors/NullIsExceptionPredicate.java b/src/java/org/apache/commons/collections/functors/NullIsExceptionPredicate.java index 47659e749..a89984c56 100644 --- a/src/java/org/apache/commons/collections/functors/NullIsExceptionPredicate.java +++ b/src/java/org/apache/commons/collections/functors/NullIsExceptionPredicate.java @@ -24,7 +24,7 @@ import org.apache.commons.collections.Predicate; * Predicate implementation that throws an exception if the input is null. * * @since Commons Collections 3.0 - * @version $Revision: 1.4 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.5 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -70,5 +70,14 @@ public final class NullIsExceptionPredicate implements Predicate, Serializable { } return iPredicate.evaluate(object); } - + + /** + * Gets the predicate. + * @return the predicate + * @since Commons Collections 3.1 + */ + public Predicate getPredicate() { + return iPredicate; + } + } diff --git a/src/java/org/apache/commons/collections/functors/NullIsFalsePredicate.java b/src/java/org/apache/commons/collections/functors/NullIsFalsePredicate.java index 7e8cb8d71..59efe021a 100644 --- a/src/java/org/apache/commons/collections/functors/NullIsFalsePredicate.java +++ b/src/java/org/apache/commons/collections/functors/NullIsFalsePredicate.java @@ -23,7 +23,7 @@ import org.apache.commons.collections.Predicate; * Predicate implementation that returns false if the input is null. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -69,5 +69,14 @@ public final class NullIsFalsePredicate implements Predicate, Serializable { } return iPredicate.evaluate(object); } - + + /** + * Gets the predicate. + * @return the predicate + * @since Commons Collections 3.1 + */ + public Predicate getPredicate() { + return iPredicate; + } + } diff --git a/src/java/org/apache/commons/collections/functors/NullIsTruePredicate.java b/src/java/org/apache/commons/collections/functors/NullIsTruePredicate.java index e4e0ad2c0..e9569de38 100644 --- a/src/java/org/apache/commons/collections/functors/NullIsTruePredicate.java +++ b/src/java/org/apache/commons/collections/functors/NullIsTruePredicate.java @@ -23,7 +23,7 @@ import org.apache.commons.collections.Predicate; * Predicate implementation that returns true if the input is null. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -69,5 +69,14 @@ public final class NullIsTruePredicate implements Predicate, Serializable { } return iPredicate.evaluate(object); } - + + /** + * Gets the predicate. + * @return the predicate + * @since Commons Collections 3.1 + */ + public Predicate getPredicate() { + return iPredicate; + } + } diff --git a/src/java/org/apache/commons/collections/functors/OnePredicate.java b/src/java/org/apache/commons/collections/functors/OnePredicate.java index 839684df2..371ebb135 100644 --- a/src/java/org/apache/commons/collections/functors/OnePredicate.java +++ b/src/java/org/apache/commons/collections/functors/OnePredicate.java @@ -24,7 +24,7 @@ import org.apache.commons.collections.Predicate; * Predicate implementation that returns true if only one of the predicates return true. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -91,5 +91,14 @@ public final class OnePredicate implements Predicate, Serializable { } return match; } - + + /** + * Gets the predicates, do not modify the array. + * @return the predicates + * @since Commons Collections 3.1 + */ + public Predicate[] getPredicates() { + return iPredicates; + } + } diff --git a/src/java/org/apache/commons/collections/functors/OrPredicate.java b/src/java/org/apache/commons/collections/functors/OrPredicate.java index eaca0eaa5..05cc44712 100644 --- a/src/java/org/apache/commons/collections/functors/OrPredicate.java +++ b/src/java/org/apache/commons/collections/functors/OrPredicate.java @@ -23,7 +23,7 @@ import org.apache.commons.collections.Predicate; * Predicate implementation that returns true if either of the predicates return true. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -71,5 +71,23 @@ public final class OrPredicate implements Predicate, Serializable { public boolean evaluate(Object object) { return (iPredicate1.evaluate(object) || iPredicate2.evaluate(object)); } - + + /** + * Gets the first predicate. + * @return the predicate + * @since Commons Collections 3.1 + */ + public Predicate getPredicate1() { + return iPredicate1; + } + + /** + * Gets the second predicate. + * @return the predicate + * @since Commons Collections 3.1 + */ + public Predicate getPredicate2() { + return iPredicate2; + } + } diff --git a/src/java/org/apache/commons/collections/functors/PredicateTransformer.java b/src/java/org/apache/commons/collections/functors/PredicateTransformer.java index cb806aec7..1ec2e4d68 100644 --- a/src/java/org/apache/commons/collections/functors/PredicateTransformer.java +++ b/src/java/org/apache/commons/collections/functors/PredicateTransformer.java @@ -25,7 +25,7 @@ import org.apache.commons.collections.Transformer; * and then returns the input. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -68,5 +68,14 @@ public class PredicateTransformer implements Transformer, Serializable { public Object transform(Object input) { return (iPredicate.evaluate(input) ? Boolean.TRUE : Boolean.FALSE); } - + + /** + * Gets the predicate. + * @return the predicate + * @since Commons Collections 3.1 + */ + public Predicate getPredicate() { + return iPredicate; + } + } diff --git a/src/java/org/apache/commons/collections/functors/SwitchClosure.java b/src/java/org/apache/commons/collections/functors/SwitchClosure.java index 07afacfd3..e697c8ab9 100644 --- a/src/java/org/apache/commons/collections/functors/SwitchClosure.java +++ b/src/java/org/apache/commons/collections/functors/SwitchClosure.java @@ -27,7 +27,7 @@ import org.apache.commons.collections.Predicate; * like a switch statement. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -138,5 +138,32 @@ public class SwitchClosure implements Closure, Serializable { } iDefault.execute(input); } - + + /** + * Gets the predicates, do not modify the array. + * @return the predicates + * @since Commons Collections 3.1 + */ + public Predicate[] getPredicates() { + return iPredicates; + } + + /** + * Gets the closures, do not modify the array. + * @return the closures + * @since Commons Collections 3.1 + */ + public Closure[] getClosures() { + return iClosures; + } + + /** + * Gets the default closure. + * @return the default closure + * @since Commons Collections 3.1 + */ + public Closure getDefaultClosure() { + return iDefault; + } + } diff --git a/src/java/org/apache/commons/collections/functors/SwitchTransformer.java b/src/java/org/apache/commons/collections/functors/SwitchTransformer.java index d191bd322..bacb38113 100644 --- a/src/java/org/apache/commons/collections/functors/SwitchTransformer.java +++ b/src/java/org/apache/commons/collections/functors/SwitchTransformer.java @@ -27,14 +27,14 @@ import org.apache.commons.collections.Transformer; * like a switch statement. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ public class SwitchTransformer implements Transformer, Serializable { /** Serial version UID */ - + static final long serialVersionUID = -6404460890903469332L; /** The tests to consider */ private final Predicate[] iPredicates; @@ -137,5 +137,32 @@ public class SwitchTransformer implements Transformer, Serializable { } return iDefault.transform(input); } - + + /** + * Gets the predicates, do not modify the array. + * @return the predicates + * @since Commons Collections 3.1 + */ + public Predicate[] getPredicates() { + return iPredicates; + } + + /** + * Gets the transformers, do not modify the array. + * @return the transformers + * @since Commons Collections 3.1 + */ + public Transformer[] getTransformers() { + return iTransformers; + } + + /** + * Gets the default transformer. + * @return the default transformer + * @since Commons Collections 3.1 + */ + public Transformer getDefaultTransformer() { + return iDefault; + } + } diff --git a/src/java/org/apache/commons/collections/functors/TransformerClosure.java b/src/java/org/apache/commons/collections/functors/TransformerClosure.java index 987ed34c4..3a8df1d1a 100644 --- a/src/java/org/apache/commons/collections/functors/TransformerClosure.java +++ b/src/java/org/apache/commons/collections/functors/TransformerClosure.java @@ -25,7 +25,7 @@ import org.apache.commons.collections.Transformer; * and ignore the result. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -69,5 +69,14 @@ public class TransformerClosure implements Closure, Serializable { public void execute(Object input) { iTransformer.transform(input); } - + + /** + * Gets the transformer. + * @return the transformer + * @since Commons Collections 3.1 + */ + public Transformer getTransformer() { + return iTransformer; + } + } diff --git a/src/java/org/apache/commons/collections/functors/TransformerPredicate.java b/src/java/org/apache/commons/collections/functors/TransformerPredicate.java index 08a4d258b..170e0a885 100644 --- a/src/java/org/apache/commons/collections/functors/TransformerPredicate.java +++ b/src/java/org/apache/commons/collections/functors/TransformerPredicate.java @@ -25,7 +25,7 @@ import org.apache.commons.collections.Transformer; * Predicate implementation that returns the result of a transformer. * * @since Commons Collections 3.0 - * @version $Revision: 1.4 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.5 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -71,5 +71,14 @@ public final class TransformerPredicate implements Predicate, Serializable { } return ((Boolean) result).booleanValue(); } - + + /** + * Gets the transformer. + * @return the transformer + * @since Commons Collections 3.1 + */ + public Transformer getTransformer() { + return iTransformer; + } + } diff --git a/src/java/org/apache/commons/collections/functors/WhileClosure.java b/src/java/org/apache/commons/collections/functors/WhileClosure.java index 26e744ea6..57c1624b2 100644 --- a/src/java/org/apache/commons/collections/functors/WhileClosure.java +++ b/src/java/org/apache/commons/collections/functors/WhileClosure.java @@ -25,7 +25,7 @@ import org.apache.commons.collections.Predicate; * like a do-while or while loop. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $ + * @version $Revision: 1.4 $ $Date: 2004/03/13 17:17:03 $ * * @author Stephen Colebourne */ @@ -86,6 +86,32 @@ public class WhileClosure implements Closure, Serializable { iClosure.execute(input); } } - -} + /** + * Gets the predicate in use. + * @return the predicate + * @since Commons Collections 3.1 + */ + public Predicate getPredicate() { + return iPredicate; + } + + /** + * Gets the closure. + * @return the closure + * @since Commons Collections 3.1 + */ + public Closure getClosure() { + return iClosure; + } + + /** + * Is the loop a do-while loop. + * @return true is do-while, false if while + * @since Commons Collections 3.1 + */ + public boolean isDoLoop() { + return iDoLoop; + } + +}