git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131723 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2004-05-16 11:16:01 +00:00
parent a916e81cb2
commit d7321ef14d
20 changed files with 138 additions and 45 deletions

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.4 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.5 $ $Date: 2004/05/16 11:16:01 $
*
* @author Stephen Colebourne
*/
@ -77,7 +77,10 @@ public final class AllPredicate implements Predicate, Serializable {
}
/**
* Return the predicate result.
* Evaluates the predicate returning true if all predicates return true.
*
* @param object the input object
* @return true if all decorated predicates return true
*/
public boolean evaluate(Object object) {
for (int i = 0; i < iPredicates.length; i++) {
@ -90,6 +93,7 @@ public final class AllPredicate implements Predicate, Serializable {
/**
* Gets the predicates, do not modify the array.
*
* @return the predicates
* @since Commons Collections 3.1
*/

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.4 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.5 $ $Date: 2004/05/16 11:16:01 $
*
* @author Stephen Colebourne
*/
@ -66,7 +66,10 @@ public final class AndPredicate implements Predicate, Serializable {
}
/**
* Return the predicate result.
* Evaluates the predicate returning true if both predicates return true.
*
* @param object the input object
* @return true if both decorated predicates return true
*/
public boolean evaluate(Object object) {
return (iPredicate1.evaluate(object) && iPredicate2.evaluate(object));
@ -74,6 +77,7 @@ public final class AndPredicate implements Predicate, Serializable {
/**
* Gets the first predicate.
*
* @return the predicate
* @since Commons Collections 3.1
*/
@ -83,6 +87,7 @@ public final class AndPredicate implements Predicate, Serializable {
/**
* Gets the second predicate.
*
* @return the predicate
* @since Commons Collections 3.1
*/

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.4 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.5 $ $Date: 2004/05/16 11:16:01 $
*
* @author Stephen Colebourne
*/
@ -77,7 +77,10 @@ public final class AnyPredicate implements Predicate, Serializable {
}
/**
* Return the predicate result.
* Evaluates the predicate returning true if any predicate returns true.
*
* @param object the input object
* @return true if any decorated predicate return true
*/
public boolean evaluate(Object object) {
for (int i = 0; i < iPredicates.length; i++) {
@ -90,6 +93,7 @@ public final class AnyPredicate implements Predicate, Serializable {
/**
* Gets the predicates, do not modify the array.
*
* @return the predicates
* @since Commons Collections 3.1
*/

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.4 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.5 $ $Date: 2004/05/16 11:16:01 $
*
* @author Stephen Colebourne
*/
@ -62,7 +62,10 @@ public final class EqualPredicate implements Predicate, Serializable {
}
/**
* Return the predicate result.
* Evaluates the predicate returning true if the input equals the stored value.
*
* @param object the input object
* @return true if input object equals stored value
*/
public boolean evaluate(Object object) {
return (iValue.equals(object));
@ -70,6 +73,7 @@ public final class EqualPredicate implements Predicate, Serializable {
/**
* Gets the value.
*
* @return the value
* @since Commons Collections 3.1
*/

View File

@ -24,7 +24,7 @@ import org.apache.commons.collections.Predicate;
* Predicate implementation that always throws an exception.
*
* @since Commons Collections 3.0
* @version $Revision: 1.6 $ $Date: 2004/03/31 23:13:04 $
* @version $Revision: 1.7 $ $Date: 2004/05/16 11:16:01 $
*
* @author Stephen Colebourne
*/
@ -54,7 +54,11 @@ public final class ExceptionPredicate implements Predicate, Serializable {
}
/**
* Always throw an exception
* Evaluates the predicate always throwing an exception.
*
* @param object the input object
* @return never
* @throws FunctorException always
*/
public boolean evaluate(Object object) {
throw new FunctorException("ExceptionPredicate invoked");

View File

@ -23,7 +23,7 @@ import org.apache.commons.collections.Predicate;
* Predicate implementation that always returns false.
*
* @since Commons Collections 3.0
* @version $Revision: 1.5 $ $Date: 2004/03/31 23:13:04 $
* @version $Revision: 1.6 $ $Date: 2004/05/16 11:16:01 $
*
* @author Stephen Colebourne
*/
@ -53,10 +53,13 @@ public final class FalsePredicate implements Predicate, Serializable {
}
/**
* Always return true.
* Evaluates the predicate returning false always.
*
* @param object the input object
* @return false always
*/
public boolean evaluate(Object object) {
return false;
}
}

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.4 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.5 $ $Date: 2004/05/16 11:16:01 $
*
* @author Stephen Colebourne
*/
@ -63,7 +63,11 @@ public final class IdentityPredicate implements Predicate, Serializable {
}
/**
* Return the predicate result.
* Evaluates the predicate returning true if the input object is identical to
* the stored object.
*
* @param object the input object
* @return true if input is the same object as the stored value
*/
public boolean evaluate(Object object) {
return (iValue == object);
@ -71,6 +75,7 @@ public final class IdentityPredicate implements Predicate, Serializable {
/**
* Gets the value.
*
* @return the value
* @since Commons Collections 3.1
*/

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.5 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.6 $ $Date: 2004/05/16 11:16:01 $
*
* @author Stephen Colebourne
*/
@ -62,7 +62,10 @@ public final class InstanceofPredicate implements Predicate, Serializable {
}
/**
* Return the predicate result.
* Evaluates the predicate returning true if the input object is of the correct type.
*
* @param object the input object
* @return true if input is of stored type
*/
public boolean evaluate(Object object) {
return (iType.isInstance(object));
@ -70,6 +73,7 @@ public final class InstanceofPredicate implements Predicate, Serializable {
/**
* Gets the type to compare to.
*
* @return the type
* @since Commons Collections 3.1
*/

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.4 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.5 $ $Date: 2004/05/16 11:16:01 $
*
* @author Stephen Colebourne
*/
@ -77,7 +77,10 @@ public final class NonePredicate implements Predicate, Serializable {
}
/**
* Return the predicate result.
* Evaluates the predicate returning false if any stored predicate returns false.
*
* @param object the input object
* @return true if none of decorated predicates return true
*/
public boolean evaluate(Object object) {
for (int i = 0; i < iPredicates.length; i++) {
@ -90,6 +93,7 @@ public final class NonePredicate implements Predicate, Serializable {
/**
* Gets the predicates, do not modify the array.
*
* @return the predicates
* @since Commons Collections 3.1
*/

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.4 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.5 $ $Date: 2004/05/16 11:16:01 $
*
* @author Stephen Colebourne
*/
@ -61,7 +61,10 @@ public final class NotPredicate implements Predicate, Serializable {
}
/**
* Return the negated predicate result.
* Evaluates the predicate returning the opposite to the stored predicate.
*
* @param object the input object
* @return true if predicate returns false
*/
public boolean evaluate(Object object) {
return !(iPredicate.evaluate(object));
@ -69,6 +72,7 @@ public final class NotPredicate implements Predicate, Serializable {
/**
* Gets the predicate.
*
* @return the predicate
* @since Commons Collections 3.1
*/

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.5 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.6 $ $Date: 2004/05/16 11:16:01 $
*
* @author Stephen Colebourne
*/
@ -62,7 +62,12 @@ public final class NullIsExceptionPredicate implements Predicate, Serializable {
}
/**
* Return true if the object equals null else call the decorated predicate.
* Evaluates the predicate returning the result of the decorated predicate
* once a null check is performed.
*
* @param object the input object
* @return true if decorated predicate returns true
* @throws FunctorException if input is null
*/
public boolean evaluate(Object object) {
if (object == null) {
@ -73,6 +78,7 @@ public final class NullIsExceptionPredicate implements Predicate, Serializable {
/**
* Gets the predicate.
*
* @return the predicate
* @since Commons Collections 3.1
*/

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.4 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.5 $ $Date: 2004/05/16 11:16:01 $
*
* @author Stephen Colebourne
*/
@ -61,7 +61,11 @@ public final class NullIsFalsePredicate implements Predicate, Serializable {
}
/**
* Return false if the object equals null else call the decorated predicate.
* Evaluates the predicate returning the result of the decorated predicate
* once a null check is performed.
*
* @param object the input object
* @return true if decorated predicate returns true, false if input is null
*/
public boolean evaluate(Object object) {
if (object == null) {
@ -72,6 +76,7 @@ public final class NullIsFalsePredicate implements Predicate, Serializable {
/**
* Gets the predicate.
*
* @return the predicate
* @since Commons Collections 3.1
*/

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.4 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.5 $ $Date: 2004/05/16 11:16:01 $
*
* @author Stephen Colebourne
*/
@ -61,7 +61,11 @@ public final class NullIsTruePredicate implements Predicate, Serializable {
}
/**
* Return true if the object equals null else call the decorated predicate.
* Evaluates the predicate returning the result of the decorated predicate
* once a null check is performed.
*
* @param object the input object
* @return true if decorated predicate returns true or input is null
*/
public boolean evaluate(Object object) {
if (object == null) {
@ -72,6 +76,7 @@ public final class NullIsTruePredicate implements Predicate, Serializable {
/**
* Gets the predicate.
*
* @return the predicate
* @since Commons Collections 3.1
*/

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.5 $ $Date: 2004/03/31 23:13:04 $
* @version $Revision: 1.6 $ $Date: 2004/05/16 11:16:01 $
*
* @author Stephen Colebourne
*/
@ -53,10 +53,13 @@ public final class NullPredicate implements Predicate, Serializable {
}
/**
* Return true if the object equals null.
* Evaluates the predicate returning true if the input is null.
*
* @param object the input object
* @return true if input is null
*/
public boolean evaluate(Object object) {
return (object == null);
}
}

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.4 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.5 $ $Date: 2004/05/16 11:16:01 $
*
* @author Stephen Colebourne
*/
@ -77,7 +77,11 @@ public final class OnePredicate implements Predicate, Serializable {
}
/**
* Return the predicate result.
* Evaluates the predicate returning true if only one decorated predicate
* returns true.
*
* @param object the input object
* @return true if only one decorated predicate returns true
*/
public boolean evaluate(Object object) {
boolean match = false;
@ -94,6 +98,7 @@ public final class OnePredicate implements Predicate, Serializable {
/**
* Gets the predicates, do not modify the array.
*
* @return the predicates
* @since Commons Collections 3.1
*/

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.4 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.5 $ $Date: 2004/05/16 11:16:01 $
*
* @author Stephen Colebourne
*/
@ -66,7 +66,10 @@ public final class OrPredicate implements Predicate, Serializable {
}
/**
* Return the predicate result.
* Evaluates the predicate returning true if either predicate returns true.
*
* @param object the input object
* @return true if either decorated predicate returns true
*/
public boolean evaluate(Object object) {
return (iPredicate1.evaluate(object) || iPredicate2.evaluate(object));
@ -74,6 +77,7 @@ public final class OrPredicate implements Predicate, Serializable {
/**
* Gets the first predicate.
*
* @return the predicate
* @since Commons Collections 3.1
*/

View File

@ -25,7 +25,7 @@ import org.apache.commons.collections.Transformer;
* another <code>Predicate</code>.
*
* @since Commons Collections 3.1
* @version $Revision: 1.2 $ $Date: 2004/03/13 17:15:17 $
* @version $Revision: 1.3 $ $Date: 2004/05/16 11:16:01 $
* @author Alban Peignier
* @author Stephen Colebourne
*/
@ -60,6 +60,9 @@ public final class TransformedPredicate implements Predicate, Serializable {
/**
* Constructor that performs no validation.
* Use <code>getInstance</code> if you want that.
*
* @param transformer the transformer to use
* @param predicate the predicate to decorate
*/
public TransformedPredicate(Transformer transformer, Predicate predicate) {
iTransformer = transformer;
@ -67,7 +70,11 @@ public final class TransformedPredicate implements Predicate, Serializable {
}
/**
* Return the predicate result.
* Evaluates the predicate returning the result of the decorated predicate
* once the input has been transformed
*
* @param object the input object which will be transformed
* @return true if decorated predicate returns true
*/
public boolean evaluate(Object object) {
Object result = iTransformer.transform(object);
@ -76,6 +83,7 @@ public final class TransformedPredicate implements Predicate, Serializable {
/**
* Gets the predicate in use.
*
* @return the predicate
*/
public Predicate getPredicate() {
@ -84,6 +92,7 @@ public final class TransformedPredicate implements Predicate, Serializable {
/**
* Gets the transformer in use.
*
* @return the transformer
*/
public Transformer getTransformer() {

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.5 $ $Date: 2004/03/13 17:17:03 $
* @version $Revision: 1.6 $ $Date: 2004/05/16 11:16:01 $
*
* @author Stephen Colebourne
*/
@ -40,7 +40,8 @@ public final class TransformerPredicate implements Predicate, Serializable {
/**
* Factory to create the predicate.
*
* @return the transformer
* @param transformer the transformer to decorate
* @return the predicate
* @throws IllegalArgumentException if the transformer is null
*/
public static Predicate getInstance(Transformer transformer) {
@ -53,6 +54,8 @@ public final class TransformerPredicate implements Predicate, Serializable {
/**
* Constructor that performs no validation.
* Use <code>getInstance</code> if you want that.
*
* @param transformer the transformer to decorate
*/
public TransformerPredicate(Transformer transformer) {
super();
@ -60,7 +63,11 @@ public final class TransformerPredicate implements Predicate, Serializable {
}
/**
* Return the predicate result.
* Evaluates the predicate returning the result of the decorated transformer.
*
* @param object the input object
* @return true if decorated transformer returns Boolean.TRUE
* @throws FunctorException if the transformer returns an invalid type
*/
public boolean evaluate(Object object) {
Object result = iTransformer.transform(object);
@ -74,6 +81,7 @@ public final class TransformerPredicate implements Predicate, Serializable {
/**
* Gets the transformer.
*
* @return the transformer
* @since Commons Collections 3.1
*/

View File

@ -23,7 +23,7 @@ import org.apache.commons.collections.Predicate;
* Predicate implementation that always returns true.
*
* @since Commons Collections 3.0
* @version $Revision: 1.5 $ $Date: 2004/03/31 23:13:04 $
* @version $Revision: 1.6 $ $Date: 2004/05/16 11:16:01 $
*
* @author Stephen Colebourne
*/
@ -53,10 +53,13 @@ public final class TruePredicate implements Predicate, Serializable {
}
/**
* Always return true.
* Evaluates the predicate returning true always.
*
* @param object the input object
* @return true always
*/
public boolean evaluate(Object object) {
return true;
}
}

View File

@ -26,7 +26,7 @@ import org.apache.commons.collections.Predicate;
* passed into the predicate.
*
* @since Commons Collections 3.0
* @version $Revision: 1.3 $ $Date: 2004/02/18 00:59:20 $
* @version $Revision: 1.4 $ $Date: 2004/05/16 11:16:01 $
*
* @author Stephen Colebourne
*/
@ -57,10 +57,14 @@ public final class UniquePredicate implements Predicate, Serializable {
}
/**
* Return the predicate result.
* Evaluates the predicate returning true if the input object hasn't been
* received yet.
*
* @param object the input object
* @return true if this is the first time the object is seen
*/
public boolean evaluate(Object object) {
return iSet.add(object);
}
}