rwaldhoff 2003/02/24 03:38:07
Modified: functor/src/test/org/apache/commons/functor/core
TestAll.java
functor/src/test/org/apache/commons/functor/core/collection
TestCollectionAlgorithms.java
functor/src/test/org/apache/commons/functor/example
Quicksort.java
Added: functor/src/java/org/apache/commons/functor/core
IsEqual.java IsInstanceOf.java IsNotEqual.java
IsNotNull.java IsNull.java
functor/src/java/org/apache/commons/functor/core/comparator
IsEquivalent.java IsGreaterThan.java
IsGreaterThanOrEqual.java IsLessThan.java
IsLessThanOrEqual.java IsNotEquivalent.java
functor/src/test/org/apache/commons/functor/core
TestIsEqual.java TestIsInstanceOf.java
TestIsNotEqual.java TestIsNotNull.java
TestIsNull.java
Removed: functor/src/java/org/apache/commons/functor/core
EqualPredicate.java InstanceOfPredicate.java
IsNotNullPredicate.java IsNullPredicate.java
NotEqualPredicate.java
functor/src/java/org/apache/commons/functor/core/comparator
Equivalent.java GreaterThan.java
GreaterThanOrEqual.java LessThan.java
LessThanOrEqual.java NotEquivalent.java
functor/src/test/org/apache/commons/functor/core
TestEqualPredicate.java
TestInstanceOfPredicate.java
TestIsNotNullPredicate.java
TestIsNullPredicate.java TestNotEqualPredicate.java
Log:
rename X[Predicate] to IsX, for several values of X
Revision Changes Path
1.1
jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/IsEqual.java
Index: IsEqual.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/IsEqual.java,v
1.1 2003/02/24 11:38:06 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.functor.core;
import java.io.Serializable;
import org.apache.commons.functor.BinaryPredicate;
/**
* [EMAIL PROTECTED] #test Tests}
* <code>true</code> iff its arguments are
* [EMAIL PROTECTED] Object#equals equal} or both
* <code>null</code>.
* <p>
* This relation is
* an equivalence relation on
* the set of objects that adhere to the
* <code>Object.equals</code> contract.
* </p>
*
* @version $Revision: 1.1 $ $Date: 2003/02/24 11:38:06 $
* @author Rodney Waldhoff
*/
public final class IsEqual implements BinaryPredicate, Serializable {
// constructor
// ------------------------------------------------------------------------
public IsEqual() {
}
// predicate interface
// ------------------------------------------------------------------------
public boolean test(Object left, Object right) {
return (null == left ? null == right : left.equals(right));
}
public boolean equals(Object that) {
return that instanceof IsEqual;
}
public int hashCode() {
return "IsEqual".hashCode();
}
public String toString() {
return "IsEqual";
}
// static attributes
// ------------------------------------------------------------------------
public static IsEqual getEqualPredicate() {
return INSTANCE;
}
// static attributes
// ------------------------------------------------------------------------
private static final IsEqual INSTANCE = new IsEqual();
}
1.1
jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/IsInstanceOf.java
Index: IsInstanceOf.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/IsInstanceOf.java,v
1.1 2003/02/24 11:38:06 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.functor.core;
import java.io.Serializable;
import org.apache.commons.functor.UnaryPredicate;
/**
* [EMAIL PROTECTED] #test Tests}
* <code>true</code> iff its argument
* [EMAIL PROTECTED] Class#isInstance is an instance}
* of some specified [EMAIL PROTECTED] Class Class}.
*
* @version $Revision: 1.1 $ $Date: 2003/02/24 11:38:06 $
* @author Rodney Waldhoff
*/
public final class IsInstanceOf implements UnaryPredicate, Serializable {
// constructor
// ------------------------------------------------------------------------
public IsInstanceOf(Class klass) {
this.klass = klass;
}
// predicate interface
// ------------------------------------------------------------------------
public boolean test(Object obj) {
return klass.isInstance(obj);
}
public boolean equals(Object that) {
if(that instanceof IsInstanceOf) {
return equals((IsInstanceOf)that);
} else {
return false;
}
}
public boolean equals(IsInstanceOf that) {
return (null != that && (null == this.klass ? null == that.klass :
this.klass.equals(that.klass)));
}
public int hashCode() {
int hash = "IsInstanceOf".hashCode();
if(null != klass) {
hash ^= klass.hashCode();
}
return hash;
}
public String toString() {
return "IsInstanceOf<" + klass + ">";
}
// attributes
// ------------------------------------------------------------------------
private Class klass;
}
1.1
jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/IsNotEqual.java
Index: IsNotEqual.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/IsNotEqual.java,v
1.1 2003/02/24 11:38:06 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.functor.core;
import java.io.Serializable;
import org.apache.commons.functor.BinaryPredicate;
/**
* [EMAIL PROTECTED] #test Tests}
* <code>true</code> iff its arguments are
* not [EMAIL PROTECTED] Object#equals equal} or both
* <code>null</code>.
* <p>
* This relation is symmetric but irreflexive
* and not transitive.
* </p>
* @version $Revision: 1.1 $ $Date: 2003/02/24 11:38:06 $
* @author Rodney Waldhoff
*/
public final class IsNotEqual implements BinaryPredicate, Serializable {
// constructor
// ------------------------------------------------------------------------
public IsNotEqual() {
}
// predicate interface
// ------------------------------------------------------------------------
public boolean test(Object left, Object right) {
return (null == left ? null != right : !left.equals(right));
}
public boolean equals(Object that) {
return that instanceof IsNotEqual;
}
public int hashCode() {
return "IsNotEqual".hashCode();
}
public String toString() {
return "IsNotEqual";
}
// static attributes
// ------------------------------------------------------------------------
public static IsNotEqual getNotEqualPredicate() {
return INSTANCE;
}
// static attributes
// ------------------------------------------------------------------------
private static final IsNotEqual INSTANCE = new IsNotEqual();
}
1.1
jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/IsNotNull.java
Index: IsNotNull.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/IsNotNull.java,v
1.1 2003/02/24 11:38:06 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.functor.core;
import java.io.Serializable;
import org.apache.commons.functor.UnaryPredicate;
/**
* [EMAIL PROTECTED] #test Tests}
* <code>false</code> iff its argument
* is <code>null</code>.
*
* @version $Revision: 1.1 $ $Date: 2003/02/24 11:38:06 $
* @author Rodney Waldhoff
*/
public final class IsNotNull implements UnaryPredicate, Serializable {
// constructor
// ------------------------------------------------------------------------
public IsNotNull() {
}
// predicate interface
// ------------------------------------------------------------------------
public boolean test(Object obj) {
return (null != obj);
}
public boolean equals(Object that) {
return that instanceof IsNotNull;
}
public int hashCode() {
return "IsNotNull".hashCode();
}
public String toString() {
return "IsNotNull";
}
// static attributes
// ------------------------------------------------------------------------
public static IsNotNull getIsNotNullPredicate() {
return INSTANCE;
}
// static attributes
// ------------------------------------------------------------------------
private static final IsNotNull INSTANCE = new IsNotNull();
}
1.1
jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/IsNull.java
Index: IsNull.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/IsNull.java,v
1.1 2003/02/24 11:38:06 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.functor.core;
import java.io.Serializable;
import org.apache.commons.functor.UnaryPredicate;
/**
* [EMAIL PROTECTED] #test Tests}
* <code>true</code> iff its argument
* is <code>null</code>.
*
* @version $Revision: 1.1 $ $Date: 2003/02/24 11:38:06 $
* @author Rodney Waldhoff
*/
public final class IsNull implements UnaryPredicate, Serializable {
// constructor
// ------------------------------------------------------------------------
public IsNull() {
}
// predicate interface
// ------------------------------------------------------------------------
public boolean test(Object obj) {
return (null == obj);
}
public boolean equals(Object that) {
return that instanceof IsNull;
}
public int hashCode() {
return "IsNull".hashCode();
}
public String toString() {
return "IsNull";
}
// static attributes
// ------------------------------------------------------------------------
public static IsNull getIsNullPredicate() {
return INSTANCE;
}
// static attributes
// ------------------------------------------------------------------------
private static final IsNull INSTANCE = new IsNull();
}
1.1
jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsEquivalent.java
Index: IsEquivalent.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsEquivalent.java,v
1.1 2003/02/24 11:38:06 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.functor.core.comparator;
import java.io.Serializable;
import java.util.Comparator;
import org.apache.commons.functor.BinaryPredicate;
/**
* A [EMAIL PROTECTED] BinaryPredicate BinaryPredicate} that [EMAIL PROTECTED] #test
tests}
* <code>true</code> iff the left argument is equal to the
* right argument under the specified [EMAIL PROTECTED] Comparator}.
* When no (or a <code>null</code> <code>Comparator</code> is specified,
* a [EMAIL PROTECTED] Comparable Comparable} <code>Comparator</code> is used.
*
* @see org.apache.commons.functor.core.IsEqual
*
* @version $Revision: 1.1 $ $Date: 2003/02/24 11:38:06 $
* @author Rodney Waldhoff
*
*/
public final class IsEquivalent implements BinaryPredicate, Serializable {
/**
* Construct an <code>IsEquivalent</code> [EMAIL PROTECTED] BinaryPredicate
predicate}
* for [EMAIL PROTECTED] Comparable Comparable}s.
*/
public IsEquivalent() {
this(null);
}
/**
* Construct an <code>IsEquivalent</code> [EMAIL PROTECTED] BinaryPredicate
predicate}
* for the given [EMAIL PROTECTED] Comparator Comparator}.
*
* @param comparator the [EMAIL PROTECTED] Comparator Comparator}, when
<code>null</code>,
* a <code>Comparator</code> for [EMAIL PROTECTED] Comparable
Comparable}s will
* be used.
*/
public IsEquivalent(Comparator comparator) {
this.comparator = null == comparator ? ComparableComparator.getInstance() :
comparator;
}
/**
* Return <code>true</code> iff the <i>left</i> parameter is
* equal to the <i>right</i> parameter under my current
* [EMAIL PROTECTED] Comparator Comparator}.
*/
public boolean test(Object left, Object right) {
return comparator.compare(left,right) == 0;
}
/**
* @see java.lang.Object#equals(Object)
*/
public boolean equals(Object that) {
if(that instanceof IsEquivalent) {
return equals((IsEquivalent)that);
} else {
return false;
}
}
/**
* @see #equals(Object)
*/
public boolean equals(IsEquivalent that) {
return null != that &&
null == comparator ? null == that.comparator :
comparator.equals(that.comparator);
}
/**
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
int hash = "IsEquivalent".hashCode();
if(null != comparator) {
hash ^= comparator.hashCode();
}
return hash;
}
/**
* @see java.lang.Object#toString()
*/
public String toString() {
return "IsEquivalent<" + comparator + ">";
}
public static final IsEquivalent getEquivalent() {
return COMPARABLE_INSTANCE;
}
private Comparator comparator = null;
private static final IsEquivalent COMPARABLE_INSTANCE = new IsEquivalent();
}
1.1
jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsGreaterThan.java
Index: IsGreaterThan.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsGreaterThan.java,v
1.1 2003/02/24 11:38:06 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.functor.core.comparator;
import java.io.Serializable;
import java.util.Comparator;
import org.apache.commons.functor.BinaryPredicate;
/**
* A [EMAIL PROTECTED] BinaryPredicate BinaryPredicate} that [EMAIL PROTECTED] #test
tests}
* <code>true</code> iff the left argument is greater than the
* right argument under the specified [EMAIL PROTECTED] Comparator}.
* When no (or a <code>null</code> <code>Comparator</code> is specified,
* a [EMAIL PROTECTED] Comparable Comparable} <code>Comparator</code> is used.
*
* @version $Revision: 1.1 $ $Date: 2003/02/24 11:38:06 $
* @author Rodney Waldhoff
*/
public final class IsGreaterThan implements BinaryPredicate, Serializable {
/**
* Construct a <code>IsGreaterThan</code> [EMAIL PROTECTED] BinaryPredicate
predicate}
* for [EMAIL PROTECTED] Comparable Comparable}s.
*/
public IsGreaterThan() {
this(null);
}
/**
* Construct a <code>IsGreaterThan</code> [EMAIL PROTECTED] BinaryPredicate
predicate}
* for the given [EMAIL PROTECTED] Comparator Comparator}.
*
* @param comparator the [EMAIL PROTECTED] Comparator Comparator}, when
<code>null</code>,
* a <code>Comparator</code> for [EMAIL PROTECTED] Comparable
Comparable}s will
* be used.
*/
public IsGreaterThan(Comparator comparator) {
this.comparator = null == comparator ? ComparableComparator.getInstance() :
comparator;
}
/**
* Return <code>true</code> iff the <i>left</i> parameter is
* greater than the <i>right</i> parameter under my current
* [EMAIL PROTECTED] Comparator Comparator}.
*/
public boolean test(Object left, Object right) {
return comparator.compare(left,right) > 0;
}
/**
* @see java.lang.Object#equals(Object)
*/
public boolean equals(Object that) {
if(that instanceof IsGreaterThan) {
return equals((IsGreaterThan)that);
} else {
return false;
}
}
/**
* @see #equals(Object)
*/
public boolean equals(IsGreaterThan that) {
return null != that &&
null == comparator ? null == that.comparator :
comparator.equals(that.comparator);
}
/**
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
int hash = "IsGreaterThan".hashCode();
if(null != comparator) {
hash ^= comparator.hashCode();
}
return hash;
}
/**
* @see java.lang.Object#toString()
*/
public String toString() {
return "IsGreaterThan<" + comparator + ">";
}
public static final IsGreaterThan getGreaterThan() {
return COMPARABLE_INSTANCE;
}
private Comparator comparator = null;
private static final IsGreaterThan COMPARABLE_INSTANCE = new IsGreaterThan();
}
1.1
jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsGreaterThanOrEqual.java
Index: IsGreaterThanOrEqual.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsGreaterThanOrEqual.java,v
1.1 2003/02/24 11:38:06 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.functor.core.comparator;
import java.io.Serializable;
import java.util.Comparator;
import org.apache.commons.functor.BinaryPredicate;
/**
* A [EMAIL PROTECTED] BinaryPredicate BinaryPredicate} that [EMAIL PROTECTED] #test
tests}
* <code>true</code> iff the left argument is greater than or equal
* to the right argument under the specified [EMAIL PROTECTED] Comparator}.
* When no (or a <code>null</code> <code>Comparator</code> is specified,
* a [EMAIL PROTECTED] Comparable Comparable} <code>Comparator</code> is used.
*
* @version $Revision: 1.1 $ $Date: 2003/02/24 11:38:06 $
* @author Rodney Waldhoff
*/
public final class IsGreaterThanOrEqual implements BinaryPredicate, Serializable {
/**
* Construct a <code>IsGreaterThanOrEqual</code> [EMAIL PROTECTED]
BinaryPredicate predicate}
* for [EMAIL PROTECTED] Comparable Comparable}s.
*/
public IsGreaterThanOrEqual() {
this(null);
}
/**
* Construct a <code>IsGreaterThanOrEqual</code> [EMAIL PROTECTED]
BinaryPredicate predicate}
* for the given [EMAIL PROTECTED] Comparator Comparator}.
*
* @param comparator the [EMAIL PROTECTED] Comparator Comparator}, when
<code>null</code>,
* a <code>Comparator</code> for [EMAIL PROTECTED] Comparable
Comparable}s will
* be used.
*/
public IsGreaterThanOrEqual(Comparator comparator) {
this.comparator = null == comparator ? ComparableComparator.getInstance() :
comparator;
}
/**
* Return <code>true</code> iff the <i>left</i> parameter is
* greater than or equal to the <i>right</i> parameter under my current
* [EMAIL PROTECTED] Comparator Comparator}.
*/
public boolean test(Object left, Object right) {
return comparator.compare(left,right) >= 0;
}
/**
* @see java.lang.Object#equals(Object)
*/
public boolean equals(Object that) {
if(that instanceof IsGreaterThanOrEqual) {
return equals((IsGreaterThanOrEqual)that);
} else {
return false;
}
}
/**
* @see #equals(Object)
*/
public boolean equals(IsGreaterThanOrEqual that) {
return null != that &&
null == comparator ? null == that.comparator :
comparator.equals(that.comparator);
}
/**
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
int hash = "IsGreaterThanOrEqual".hashCode();
if(null != comparator) {
hash ^= comparator.hashCode();
}
return hash;
}
/**
* @see java.lang.Object#toString()
*/
public String toString() {
return "IsGreaterThanOrEqual<" + comparator + ">";
}
public static final IsGreaterThanOrEqual getGreaterThanOrEqual() {
return COMPARABLE_INSTANCE;
}
private Comparator comparator = null;
private static final IsGreaterThanOrEqual COMPARABLE_INSTANCE = new
IsGreaterThanOrEqual();
}
1.1
jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsLessThan.java
Index: IsLessThan.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsLessThan.java,v
1.1 2003/02/24 11:38:06 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.functor.core.comparator;
import java.io.Serializable;
import java.util.Comparator;
import org.apache.commons.functor.BinaryPredicate;
/**
* A [EMAIL PROTECTED] BinaryPredicate BinaryPredicate} that [EMAIL PROTECTED] #test
tests}
* <code>true</code> iff the left argument is greater than the
* right argument under the specified [EMAIL PROTECTED] Comparator}.
* When no (or a <code>null</code> <code>Comparator</code> is specified,
* a [EMAIL PROTECTED] Comparable Comparable} <code>Comparator</code> is used.
*
* @version $Revision: 1.1 $ $Date: 2003/02/24 11:38:06 $
* @author Rodney Waldhoff
*/
public final class IsLessThan implements BinaryPredicate, Serializable {
/**
* Construct a <code>IsLessThan</code> [EMAIL PROTECTED] BinaryPredicate
predicate}
* for [EMAIL PROTECTED] Comparable Comparable}s.
*/
public IsLessThan() {
this(null);
}
/**
* Construct a <code>IsLessThan</code> [EMAIL PROTECTED] BinaryPredicate
predicate}
* for the given [EMAIL PROTECTED] Comparator Comparator}.
*
* @param comparator the [EMAIL PROTECTED] Comparator Comparator}, when
<code>null</code>,
* a <code>Comparator</code> for [EMAIL PROTECTED] Comparable
Comparable}s will
* be used.
*/
public IsLessThan(Comparator comparator) {
this.comparator = null == comparator ? ComparableComparator.getInstance() :
comparator;
}
/**
* Return <code>true</code> iff the <i>left</i> parameter is
* less than the <i>right</i> parameter under my current
* [EMAIL PROTECTED] Comparator Comparator}.
*/
public boolean test(Object left, Object right) {
return comparator.compare(left,right) < 0;
}
/**
* @see java.lang.Object#equals(Object)
*/
public boolean equals(Object that) {
if(that instanceof IsLessThan) {
return equals((IsLessThan)that);
} else {
return false;
}
}
/**
* @see #equals(Object)
*/
public boolean equals(IsLessThan that) {
return null != that &&
null == comparator ? null == that.comparator :
comparator.equals(that.comparator);
}
/**
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
int hash = "IsLessThan".hashCode();
if(null != comparator) {
hash ^= comparator.hashCode();
}
return hash;
}
/**
* @see java.lang.Object#toString()
*/
public String toString() {
return "IsLessThan<" + comparator + ">";
}
public static final IsLessThan getLessThan() {
return COMPARABLE_INSTANCE;
}
private Comparator comparator = null;
private static final IsLessThan COMPARABLE_INSTANCE = new IsLessThan();
}
1.1
jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsLessThanOrEqual.java
Index: IsLessThanOrEqual.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsLessThanOrEqual.java,v
1.1 2003/02/24 11:38:06 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.functor.core.comparator;
import java.io.Serializable;
import java.util.Comparator;
import org.apache.commons.functor.BinaryPredicate;
/**
* A [EMAIL PROTECTED] BinaryPredicate BinaryPredicate} that [EMAIL PROTECTED] #test
tests}
* <code>true</code> iff the left argument is less than or equal to the
* right argument under the specified [EMAIL PROTECTED] Comparator}.
* When no (or a <code>null</code> <code>Comparator</code> is specified,
* a [EMAIL PROTECTED] Comparable Comparable} <code>Comparator</code> is used.
*
* @version $Revision: 1.1 $ $Date: 2003/02/24 11:38:06 $
* @author Rodney Waldhoff
*/
public final class IsLessThanOrEqual implements BinaryPredicate, Serializable {
/**
* Construct a <code>IsLessThanOrEqual</code> [EMAIL PROTECTED] BinaryPredicate
predicate}
* for [EMAIL PROTECTED] Comparable Comparable}s.
*/
public IsLessThanOrEqual() {
this(null);
}
/**
* Construct a <code>IsLessThanOrEqual</code> [EMAIL PROTECTED] BinaryPredicate
predicate}
* for the given [EMAIL PROTECTED] Comparator Comparator}.
*
* @param comparator the [EMAIL PROTECTED] Comparator Comparator}, when
<code>null</code>,
* a <code>Comparator</code> for [EMAIL PROTECTED] Comparable
Comparable}s will
* be used.
*/
public IsLessThanOrEqual(Comparator comparator) {
this.comparator = null == comparator ? ComparableComparator.getInstance() :
comparator;
}
/**
* Return <code>true</code> iff the <i>left</i> parameter is
* less than or equal to the <i>right</i> parameter under my current
* [EMAIL PROTECTED] Comparator Comparator}.
*/
public boolean test(Object left, Object right) {
return comparator.compare(left,right) <= 0;
}
/**
* @see java.lang.Object#equals(Object)
*/
public boolean equals(Object that) {
if(that instanceof IsLessThanOrEqual) {
return equals((IsLessThanOrEqual)that);
} else {
return false;
}
}
/**
* @see #equals(Object)
*/
public boolean equals(IsLessThanOrEqual that) {
return null != that &&
null == comparator ? null == that.comparator :
comparator.equals(that.comparator);
}
/**
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
int hash = "IsLessThanOrEqual".hashCode();
if(null != comparator) {
hash ^= comparator.hashCode();
}
return hash;
}
/**
* @see java.lang.Object#toString()
*/
public String toString() {
return "IsLessThanOrEqual<" + comparator + ">";
}
public static final IsLessThanOrEqual getLessThanOrEqual() {
return COMPARABLE_INSTANCE;
}
private Comparator comparator = null;
private static final IsLessThanOrEqual COMPARABLE_INSTANCE = new
IsLessThanOrEqual();
}
1.1
jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsNotEquivalent.java
Index: IsNotEquivalent.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/core/comparator/IsNotEquivalent.java,v
1.1 2003/02/24 11:38:06 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.functor.core.comparator;
import java.io.Serializable;
import java.util.Comparator;
import org.apache.commons.functor.BinaryPredicate;
/**
* A [EMAIL PROTECTED] BinaryPredicate BinaryPredicate} that [EMAIL PROTECTED] #test
tests}
* <code>true</code> iff the left argument is not equal to the
* right argument under the specified [EMAIL PROTECTED] Comparator}.
* When no (or a <code>null</code> <code>Comparator</code> is specified,
* a [EMAIL PROTECTED] Comparable Comparable} <code>Comparator</code> is used.
*
* @see org.apache.commons.functor.core.IsEqual
*
* @version $Revision: 1.1 $ $Date: 2003/02/24 11:38:06 $
* @author Rodney Waldhoff
*
*/
public final class IsNotEquivalent implements BinaryPredicate, Serializable {
/**
* Construct a <code>IsNotEquivalent</code> [EMAIL PROTECTED] BinaryPredicate
predicate}
* for [EMAIL PROTECTED] Comparable Comparable}s.
*/
public IsNotEquivalent() {
this(null);
}
/**
* Construct a <code>IsNotEquivalent</code> [EMAIL PROTECTED] BinaryPredicate
predicate}
* for the given [EMAIL PROTECTED] Comparator Comparator}.
*
* @param comparator the [EMAIL PROTECTED] Comparator Comparator}, when
<code>null</code>,
* a <code>Comparator</code> for [EMAIL PROTECTED] Comparable
Comparable}s will
* be used.
*/
public IsNotEquivalent(Comparator comparator) {
this.comparator = null == comparator ? ComparableComparator.getInstance() :
comparator;
}
/**
* Return <code>true</code> iff the <i>left</i> parameter is
* not equal to the <i>right</i> parameter under my current
* [EMAIL PROTECTED] Comparator Comparator}.
*/
public boolean test(Object left, Object right) {
return comparator.compare(left,right) != 0;
}
/**
* @see java.lang.Object#equals(Object)
*/
public boolean equals(Object that) {
if(that instanceof IsNotEquivalent) {
return equals((IsNotEquivalent)that);
} else {
return false;
}
}
/**
* @see #equals(Object)
*/
public boolean equals(IsNotEquivalent that) {
return null != that &&
null == comparator ? null == that.comparator :
comparator.equals(that.comparator);
}
/**
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
int hash = "IsNotEquivalent".hashCode();
if(null != comparator) {
hash ^= comparator.hashCode();
}
return hash;
}
/**
* @see java.lang.Object#toString()
*/
public String toString() {
return "IsNotEquivalent<" + comparator + ">";
}
public static final IsNotEquivalent getNotEquivalent() {
return COMPARABLE_INSTANCE;
}
private Comparator comparator = null;
private static final IsNotEquivalent COMPARABLE_INSTANCE = new IsNotEquivalent();
}
1.5 +7 -7
jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestAll.java
Index: TestAll.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestAll.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TestAll.java 20 Feb 2003 01:12:41 -0000 1.4
+++ TestAll.java 24 Feb 2003 11:38:06 -0000 1.5
@@ -78,11 +78,11 @@
suite.addTest(TestIdentityFunction.suite());
suite.addTest(TestLeftIdentityFunction.suite());
suite.addTest(TestRightIdentityFunction.suite());
- suite.addTest(TestInstanceOfPredicate.suite());
- suite.addTest(TestIsNullPredicate.suite());
- suite.addTest(TestIsNotNullPredicate.suite());
- suite.addTest(TestEqualPredicate.suite());
- suite.addTest(TestNotEqualPredicate.suite());
+ suite.addTest(TestIsInstanceOf.suite());
+ suite.addTest(TestIsNull.suite());
+ suite.addTest(TestIsNotNull.suite());
+ suite.addTest(TestIsEqual.suite());
+ suite.addTest(TestIsNotEqual.suite());
suite.addTest(TestIdentityPredicate.suite());
suite.addTest(TestLeftIdentityPredicate.suite());
suite.addTest(TestRightIdentityPredicate.suite());
1.1
jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestIsEqual.java
Index: TestIsEqual.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestIsEqual.java,v
1.1 2003/02/24 11:38:06 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.functor.core;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.BinaryPredicate;
/**
* @version $Revision: 1.1 $ $Date: 2003/02/24 11:38:06 $
* @author Rodney Waldhoff
*/
public class TestIsEqual extends BaseFunctorTest {
// Conventional
// ------------------------------------------------------------------------
public TestIsEqual(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(TestIsEqual.class);
}
// Functor Testing Framework
// ------------------------------------------------------------------------
protected Object makeFunctor() {
return new IsEqual();
}
// Lifecycle
// ------------------------------------------------------------------------
public void setUp() throws Exception {
super.setUp();
}
public void tearDown() throws Exception {
super.tearDown();
}
// Tests
// ------------------------------------------------------------------------
public void testTest() throws Exception {
IsEqual p = new IsEqual();
assertTrue("For symmetry, two nulls should be equal",p.test(null,null));
assertTrue(p.test("foo","foo"));
assertTrue(!p.test(null,"foo"));
assertTrue(!p.test("foo",null));
assertTrue(p.test(new Integer(3),new Integer(3)));
assertTrue(!p.test(null,new Integer(3)));
assertTrue(!p.test(new Integer(3),null));
assertTrue(!p.test(new Integer(3),new Integer(4)));
assertTrue(!p.test(new Integer(4),new Integer(3)));
assertTrue(!p.test("3",new Integer(3)));
assertTrue(!p.test(new Integer(3),"3"));
}
public void testEquals() throws Exception {
BinaryPredicate f = new IsEqual();
assertEquals(f,f);
assertObjectsAreEqual(f,new IsEqual());
assertObjectsAreEqual(f,IsEqual.getEqualPredicate());
assertObjectsAreNotEqual(f,ConstantPredicate.getTruePredicate());
}
public void testConstant() throws Exception {
assertEquals(IsEqual.getEqualPredicate(),IsEqual.getEqualPredicate());
assertSame(IsEqual.getEqualPredicate(),IsEqual.getEqualPredicate());
}
}
1.1
jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestIsInstanceOf.java
Index: TestIsInstanceOf.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestIsInstanceOf.java,v
1.1 2003/02/24 11:38:06 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.functor.core;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.UnaryPredicate;
/**
* @version $Revision: 1.1 $ $Date: 2003/02/24 11:38:06 $
* @author Rodney Waldhoff
*/
public class TestIsInstanceOf extends BaseFunctorTest {
// Conventional
// ------------------------------------------------------------------------
public TestIsInstanceOf(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(TestIsInstanceOf.class);
}
// Functor Testing Framework
// ------------------------------------------------------------------------
protected Object makeFunctor() {
return new IsInstanceOf(String.class);
}
// Lifecycle
// ------------------------------------------------------------------------
public void setUp() throws Exception {
super.setUp();
}
public void tearDown() throws Exception {
super.tearDown();
}
// Tests
// ------------------------------------------------------------------------
public void testTest() throws Exception {
UnaryPredicate p = new IsInstanceOf(Number.class);
assertTrue(!p.test(null));
assertTrue(!p.test("foo"));
assertTrue(p.test(new Integer(3)));
assertTrue(p.test((Object)(new Integer(3))));
assertTrue(p.test((new Long(3L))));
}
public void testInstanceOfNull() throws Exception {
UnaryPredicate p = new IsInstanceOf(null);
try {
p.test("foo");
fail("Expected NullPointerException");
} catch(NullPointerException e) {
// expected
}
}
public void testEquals() throws Exception {
UnaryPredicate p = new IsInstanceOf(Object.class);
assertEquals(p,p);
assertObjectsAreEqual(p,new IsInstanceOf(Object.class));
assertObjectsAreNotEqual(p,ConstantPredicate.getTruePredicate());
assertObjectsAreNotEqual(p,new IsInstanceOf(null));
assertObjectsAreNotEqual(p,new IsInstanceOf(String.class));
}
}
1.1
jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestIsNotEqual.java
Index: TestIsNotEqual.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestIsNotEqual.java,v
1.1 2003/02/24 11:38:06 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.functor.core;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.BinaryPredicate;
/**
* @version $Revision: 1.1 $ $Date: 2003/02/24 11:38:06 $
* @author Rodney Waldhoff
*/
public class TestIsNotEqual extends BaseFunctorTest {
// Conventional
// ------------------------------------------------------------------------
public TestIsNotEqual(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(TestIsNotEqual.class);
}
// Functor Testing Framework
// ------------------------------------------------------------------------
protected Object makeFunctor() {
return new IsNotEqual();
}
// Lifecycle
// ------------------------------------------------------------------------
public void setUp() throws Exception {
super.setUp();
}
public void tearDown() throws Exception {
super.tearDown();
}
// Tests
// ------------------------------------------------------------------------
public void testTest() throws Exception {
IsNotEqual p = new IsNotEqual();
assertTrue("For symmetry, two nulls should be equal",!p.test(null,null));
assertTrue(!p.test("foo","foo"));
assertTrue(p.test(null,"foo"));
assertTrue(p.test("foo",null));
assertTrue(!p.test(new Integer(3),new Integer(3)));
assertTrue(p.test(null,new Integer(3)));
assertTrue(p.test(new Integer(3),null));
assertTrue(p.test(new Integer(3),new Integer(4)));
assertTrue(p.test(new Integer(4),new Integer(3)));
assertTrue(p.test("3",new Integer(3)));
assertTrue(p.test(new Integer(3),"3"));
}
public void testEquals() throws Exception {
BinaryPredicate p = new IsNotEqual();
assertEquals(p,p);
assertObjectsAreEqual(p,new IsNotEqual());
assertObjectsAreEqual(p,IsNotEqual.getNotEqualPredicate());
assertObjectsAreNotEqual(p,ConstantPredicate.getTruePredicate());
}
public void testConstant() throws Exception {
assertEquals(IsNotEqual.getNotEqualPredicate(),IsNotEqual.getNotEqualPredicate());
assertSame(IsNotEqual.getNotEqualPredicate(),IsNotEqual.getNotEqualPredicate());
}
}
1.1
jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestIsNotNull.java
Index: TestIsNotNull.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestIsNotNull.java,v
1.1 2003/02/24 11:38:06 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.functor.core;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.UnaryPredicate;
/**
* @version $Revision: 1.1 $ $Date: 2003/02/24 11:38:06 $
* @author Rodney Waldhoff
*/
public class TestIsNotNull extends BaseFunctorTest {
// Conventional
// ------------------------------------------------------------------------
public TestIsNotNull(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(TestIsNotNull.class);
}
// Functor Testing Framework
// ------------------------------------------------------------------------
protected Object makeFunctor() {
return new IsNotNull();
}
// Lifecycle
// ------------------------------------------------------------------------
public void setUp() throws Exception {
super.setUp();
}
public void tearDown() throws Exception {
super.tearDown();
}
// Tests
// ------------------------------------------------------------------------
public void testTest() throws Exception {
UnaryPredicate p = new IsNotNull();
assertTrue(!p.test(null));
assertTrue(p.test("foo"));
assertTrue(p.test(new Integer(3)));
}
public void testEquals() throws Exception {
UnaryPredicate p = new IsNotNull();
assertEquals(p,p);
assertObjectsAreEqual(p,new IsNotNull());
assertObjectsAreEqual(p,IsNotNull.getIsNotNullPredicate());
assertObjectsAreNotEqual(p,ConstantPredicate.getTruePredicate());
}
public void testConstant() throws Exception {
assertEquals(IsNotNull.getIsNotNullPredicate(),IsNotNull.getIsNotNullPredicate());
assertSame(IsNotNull.getIsNotNullPredicate(),IsNotNull.getIsNotNullPredicate());
}
}
1.1
jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestIsNull.java
Index: TestIsNull.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/TestIsNull.java,v
1.1 2003/02/24 11:38:06 rwaldhoff Exp $
* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.functor.core;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.UnaryPredicate;
/**
* @version $Revision: 1.1 $ $Date: 2003/02/24 11:38:06 $
* @author Rodney Waldhoff
*/
public class TestIsNull extends BaseFunctorTest {
// Conventional
// ------------------------------------------------------------------------
public TestIsNull(String testName) {
super(testName);
}
public static Test suite() {
return new TestSuite(TestIsNull.class);
}
// Functor Testing Framework
// ------------------------------------------------------------------------
protected Object makeFunctor() {
return new IsNull();
}
// Lifecycle
// ------------------------------------------------------------------------
public void setUp() throws Exception {
super.setUp();
}
public void tearDown() throws Exception {
super.tearDown();
}
// Tests
// ------------------------------------------------------------------------
public void testTest() throws Exception {
UnaryPredicate p = new IsNull();
assertTrue(p.test(null));
assertTrue(!p.test("foo"));
assertTrue(!p.test(new Integer(3)));
}
public void testEquals() throws Exception {
UnaryPredicate p = new IsNull();
assertEquals(p,p);
assertObjectsAreEqual(p,new IsNull());
assertObjectsAreEqual(p,IsNull.getIsNullPredicate());
assertObjectsAreNotEqual(p,ConstantPredicate.getTruePredicate());
}
public void testConstant() throws Exception {
assertEquals(IsNull.getIsNullPredicate(),IsNull.getIsNullPredicate());
assertSame(IsNull.getIsNullPredicate(),IsNull.getIsNullPredicate());
}
}
1.4 +5 -5
jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/collection/TestCollectionAlgorithms.java
Index: TestCollectionAlgorithms.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/core/collection/TestCollectionAlgorithms.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestCollectionAlgorithms.java 19 Feb 2003 12:34:20 -0000 1.3
+++ TestCollectionAlgorithms.java 24 Feb 2003 11:38:07 -0000 1.4
@@ -73,7 +73,7 @@
import org.apache.commons.functor.UnaryPredicate;
import org.apache.commons.functor.UnaryProcedure;
import org.apache.commons.functor.adapter.LeftBoundPredicate;
-import org.apache.commons.functor.core.EqualPredicate;
+import org.apache.commons.functor.core.IsEqual;
import org.apache.commons.functor.core.IdentityFunction;
/**
@@ -247,8 +247,8 @@
private List evens = null;
private List listWithDuplicates = null;
private int sum = 0;
- private UnaryPredicate equalsThree =
LeftBoundPredicate.bind(EqualPredicate.getEqualPredicate(),new Integer(3));
- private UnaryPredicate equalsTwentyThree =
LeftBoundPredicate.bind(EqualPredicate.getEqualPredicate(),new Integer(23));
+ private UnaryPredicate equalsThree =
LeftBoundPredicate.bind(IsEqual.getEqualPredicate(),new Integer(3));
+ private UnaryPredicate equalsTwentyThree =
LeftBoundPredicate.bind(IsEqual.getEqualPredicate(),new Integer(23));
private UnaryPredicate isEven = new UnaryPredicate() {
public boolean test(Object obj) {
return ((Number)obj).intValue() % 2 == 0;
1.3 +6 -6
jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/Quicksort.java
Index: Quicksort.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/example/Quicksort.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Quicksort.java 21 Feb 2003 00:12:29 -0000 1.2
+++ Quicksort.java 24 Feb 2003 11:38:07 -0000 1.3
@@ -73,8 +73,8 @@
import org.apache.commons.functor.core.ConstantFunction;
import org.apache.commons.functor.core.collection.CollectionAlgorithms;
import org.apache.commons.functor.core.collection.IsEmpty;
-import org.apache.commons.functor.core.comparator.GreaterThanOrEqual;
-import org.apache.commons.functor.core.comparator.LessThan;
+import org.apache.commons.functor.core.comparator.IsGreaterThanOrEqual;
+import org.apache.commons.functor.core.comparator.IsLessThan;
import org.apache.commons.functor.core.composite.ConditionalUnaryFunction;
@@ -439,7 +439,7 @@
return CollectionAlgorithms.select(
((List)tail).iterator(),
RightBoundPredicate.bind(
- LessThan.getLessThan(),
+ IsLessThan.getLessThan(),
head));
}
};
@@ -449,7 +449,7 @@
return CollectionAlgorithms.select(
((List)tail).iterator(),
RightBoundPredicate.bind(
- GreaterThanOrEqual.getGreaterThanOrEqual(),
+ IsGreaterThanOrEqual.getGreaterThanOrEqual(),
head));
}
};
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]