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
This commit is contained in:
Stephen Colebourne 2004-03-13 17:17:03 +00:00
parent a02862092a
commit 5bd1ed25de
29 changed files with 412 additions and 61 deletions

View File

@ -25,22 +25,23 @@ No interface changes, or deprecations have occurred.
<center><h3>NEW CLASSES</h3></center>
<ul>
<li>[26946] TransformedPredicate - A predicate where the input object is transformed</li>
<li>TransformedPredicate - A predicate where the input object is transformed [26946]</li>
</ul>
<center><h3>ENHANCEMENTS</h3></center>
<ul>
<li>MultiKey - Add getKey(index) and size() methods and make constructor public</li>
<li>AbstractHashedMap,AbstractLinkedMap - Add methods to access entry methods when protected scope blocks</li>
<li>Functors - Add get methods to retrieve internal state [27515]</li>
</ul>
<center><h3>BUG FIXES</h3></center>
<ul>
<li>[27159] AbstractHashedMap subclasses failed to clone() correctly</li>
<li>AbstractHashedMap subclasses failed to clone() correctly [27159]</li>
</ul>
<center><h3>JAVADOC</h3></center>
<ul>
<li>[26470] TreeBidiMap - Add javadoc about requiring Comparable entries</li>
<li>TreeBidiMap - Add javadoc about requiring Comparable entries [26470]</li>
<li>MultiKey - Add extra explanatations, examples and warnings</li>
</ul>

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}