scolebourne 2004/05/31 09:43:17
Modified: collections/src/java/org/apache/commons/collections/functors
NullIsExceptionPredicate.java NonePredicate.java
AndPredicate.java AnyPredicate.java
OrPredicate.java OnePredicate.java
NotPredicate.java TransformedPredicate.java
NullIsFalsePredicate.java AllPredicate.java
NullIsTruePredicate.java
Added: collections/src/java/org/apache/commons/collections/functors
PredicateDecorator.java
Log:
Add PredicateDecorator to provide consistent access to predicates
based on code from Brian Lloyd-Newberry
Revision Changes Path
1.7 +6 -6 jakarta-commons/collections/src/java/org/apache/commons/collections/functors/NullIsExceptionPredicate.java
Index: NullIsExceptionPredicate.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/functors/NullIsExceptionPredicate.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- NullIsExceptionPredicate.java 16 May 2004 11:16:01 -0000 1.6
+++ NullIsExceptionPredicate.java 31 May 2004 16:43:17 -0000 1.7
@@ -28,7 +28,7 @@
*
* @author Stephen Colebourne
*/
-public final class NullIsExceptionPredicate implements Predicate, Serializable {
+public final class NullIsExceptionPredicate implements Predicate, PredicateDecorator, Serializable
{
/** Serial version UID */
static final long serialVersionUID = 3243449850504576071L;
@@ -77,13 +77,13 @@
}
/**
- * Gets the predicate.
+ * Gets the predicate being decorated.
*
- * @return the predicate
+ * @return the predicate as the only element in an array
* @since Commons Collections 3.1
*/
- public Predicate getPredicate() {
- return iPredicate;
+ public Predicate[] getPredicates() {
+ return new Predicate[] {iPredicate};
}
}
1.6 +2 -2 jakarta-commons/collections/src/java/org/apache/commons/collections/functors/NonePredicate.java
Index: NonePredicate.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/functors/NonePredicate.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- NonePredicate.java 16 May 2004 11:16:01 -0000 1.5
+++ NonePredicate.java 31 May 2004 16:43:17 -0000 1.6
@@ -28,7 +28,7 @@
*
* @author Stephen Colebourne
*/
-public final class NonePredicate implements Predicate, Serializable {
+public final class NonePredicate implements Predicate, PredicateDecorator, Serializable
{
/** Serial version UID */
static final long serialVersionUID = 2007613066565892961L;
1.6 +6 -16 jakarta-commons/collections/src/java/org/apache/commons/collections/functors/AndPredicate.java
Index: AndPredicate.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/functors/AndPredicate.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AndPredicate.java 16 May 2004 11:16:01 -0000 1.5
+++ AndPredicate.java 31 May 2004 16:43:17 -0000 1.6
@@ -27,7 +27,7 @@
*
* @author Stephen Colebourne
*/
-public final class AndPredicate implements Predicate, Serializable {
+public final class AndPredicate implements Predicate, PredicateDecorator, Serializable
{
/** Serial version UID */
static final long serialVersionUID = 4189014213763186912L;
@@ -76,23 +76,13 @@
}
/**
- * Gets the first predicate.
+ * Gets the two predicates being decorated as an array.
*
- * @return the predicate
+ * @return the predicates
* @since Commons Collections 3.1
*/
- public Predicate getPredicate1() {
- return iPredicate1;
- }
-
- /**
- * Gets the second predicate.
- *
- * @return the predicate
- * @since Commons Collections 3.1
- */
- public Predicate getPredicate2() {
- return iPredicate2;
+ public Predicate[] getPredicates() {
+ return new Predicate[] {iPredicate1, iPredicate2};
}
}
1.6 +2 -2 jakarta-commons/collections/src/java/org/apache/commons/collections/functors/AnyPredicate.java
Index: AnyPredicate.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/functors/AnyPredicate.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AnyPredicate.java 16 May 2004 11:16:01 -0000 1.5
+++ AnyPredicate.java 31 May 2004 16:43:17 -0000 1.6
@@ -28,7 +28,7 @@
*
* @author Stephen Colebourne
*/
-public final class AnyPredicate implements Predicate, Serializable {
+public final class AnyPredicate implements Predicate, PredicateDecorator, Serializable
{
/** Serial version UID */
static final long serialVersionUID = 7429999530934647542L;
1.6 +6 -15 jakarta-commons/collections/src/java/org/apache/commons/collections/functors/OrPredicate.java
Index: OrPredicate.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/functors/OrPredicate.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- OrPredicate.java 16 May 2004 11:16:01 -0000 1.5
+++ OrPredicate.java 31 May 2004 16:43:17 -0000 1.6
@@ -27,7 +27,7 @@
*
* @author Stephen Colebourne
*/
-public final class OrPredicate implements Predicate, Serializable {
+public final class OrPredicate implements Predicate, PredicateDecorator, Serializable {
/** Serial version UID */
static final long serialVersionUID = -8791518325735182855L;
@@ -76,22 +76,13 @@
}
/**
- * Gets the first predicate.
+ * Gets the two predicates being decorated as an array.
*
- * @return the predicate
+ * @return the predicates
* @since Commons Collections 3.1
*/
- public Predicate getPredicate1() {
- return iPredicate1;
- }
-
- /**
- * Gets the second predicate.
- * @return the predicate
- * @since Commons Collections 3.1
- */
- public Predicate getPredicate2() {
- return iPredicate2;
+ public Predicate[] getPredicates() {
+ return new Predicate[] {iPredicate1, iPredicate2};
}
}
1.6 +2 -2 jakarta-commons/collections/src/java/org/apache/commons/collections/functors/OnePredicate.java
Index: OnePredicate.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/functors/OnePredicate.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- OnePredicate.java 16 May 2004 11:16:01 -0000 1.5
+++ OnePredicate.java 31 May 2004 16:43:17 -0000 1.6
@@ -28,7 +28,7 @@
*
* @author Stephen Colebourne
*/
-public final class OnePredicate implements Predicate, Serializable {
+public final class OnePredicate implements Predicate, PredicateDecorator, Serializable
{
/** Serial version UID */
static final long serialVersionUID = -8125389089924745785L;
1.6 +6 -6 jakarta-commons/collections/src/java/org/apache/commons/collections/functors/NotPredicate.java
Index: NotPredicate.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/functors/NotPredicate.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- NotPredicate.java 16 May 2004 11:16:01 -0000 1.5
+++ NotPredicate.java 31 May 2004 16:43:17 -0000 1.6
@@ -27,7 +27,7 @@
*
* @author Stephen Colebourne
*/
-public final class NotPredicate implements Predicate, Serializable {
+public final class NotPredicate implements Predicate, PredicateDecorator, Serializable
{
/** Serial version UID */
static final long serialVersionUID = -2654603322338049674L;
@@ -71,13 +71,13 @@
}
/**
- * Gets the predicate.
+ * Gets the predicate being decorated.
*
- * @return the predicate
+ * @return the predicate as the only element in an array
* @since Commons Collections 3.1
*/
- public Predicate getPredicate() {
- return iPredicate;
+ public Predicate[] getPredicates() {
+ return new Predicate[] {iPredicate};
}
}
1.4 +7 -6 jakarta-commons/collections/src/java/org/apache/commons/collections/functors/TransformedPredicate.java
Index: TransformedPredicate.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/functors/TransformedPredicate.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TransformedPredicate.java 16 May 2004 11:16:01 -0000 1.3
+++ TransformedPredicate.java 31 May 2004 16:43:17 -0000 1.4
@@ -29,7 +29,7 @@
* @author Alban Peignier
* @author Stephen Colebourne
*/
-public final class TransformedPredicate implements Predicate, Serializable {
+public final class TransformedPredicate implements Predicate, PredicateDecorator, Serializable
{
/** Serial version UID */
static final long serialVersionUID = -5596090919668315834L;
@@ -82,12 +82,13 @@
}
/**
- * Gets the predicate in use.
+ * Gets the predicate being decorated.
*
- * @return the predicate
+ * @return the predicate as the only element in an array
+ * @since Commons Collections 3.1
*/
- public Predicate getPredicate() {
- return iPredicate;
+ public Predicate[] getPredicates() {
+ return new Predicate[] {iPredicate};
}
/**
1.6 +6 -6 jakarta-commons/collections/src/java/org/apache/commons/collections/functors/NullIsFalsePredicate.java
Index: NullIsFalsePredicate.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/functors/NullIsFalsePredicate.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- NullIsFalsePredicate.java 16 May 2004 11:16:01 -0000 1.5
+++ NullIsFalsePredicate.java 31 May 2004 16:43:17 -0000 1.6
@@ -27,7 +27,7 @@
*
* @author Stephen Colebourne
*/
-public final class NullIsFalsePredicate implements Predicate, Serializable {
+public final class NullIsFalsePredicate implements Predicate, PredicateDecorator, Serializable
{
/** Serial version UID */
static final long serialVersionUID = -2997501534564735525L;
@@ -75,13 +75,13 @@
}
/**
- * Gets the predicate.
+ * Gets the predicate being decorated.
*
- * @return the predicate
+ * @return the predicate as the only element in an array
* @since Commons Collections 3.1
*/
- public Predicate getPredicate() {
- return iPredicate;
+ public Predicate[] getPredicates() {
+ return new Predicate[] {iPredicate};
}
}
1.6 +2 -2 jakarta-commons/collections/src/java/org/apache/commons/collections/functors/AllPredicate.java
Index: AllPredicate.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/functors/AllPredicate.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AllPredicate.java 16 May 2004 11:16:01 -0000 1.5
+++ AllPredicate.java 31 May 2004 16:43:17 -0000 1.6
@@ -28,7 +28,7 @@
*
* @author Stephen Colebourne
*/
-public final class AllPredicate implements Predicate, Serializable {
+public final class AllPredicate implements Predicate, PredicateDecorator, Serializable
{
/** Serial version UID */
static final long serialVersionUID = -3094696765038308799L;
1.6 +6 -6 jakarta-commons/collections/src/java/org/apache/commons/collections/functors/NullIsTruePredicate.java
Index: NullIsTruePredicate.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/functors/NullIsTruePredicate.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- NullIsTruePredicate.java 16 May 2004 11:16:01 -0000 1.5
+++ NullIsTruePredicate.java 31 May 2004 16:43:17 -0000 1.6
@@ -27,7 +27,7 @@
*
* @author Stephen Colebourne
*/
-public final class NullIsTruePredicate implements Predicate, Serializable {
+public final class NullIsTruePredicate implements Predicate, PredicateDecorator, Serializable
{
/** Serial version UID */
static final long serialVersionUID = -7625133768987126273L;
@@ -75,13 +75,13 @@
}
/**
- * Gets the predicate.
+ * Gets the predicate being decorated.
*
- * @return the predicate
+ * @return the predicate as the only element in an array
* @since Commons Collections 3.1
*/
- public Predicate getPredicate() {
- return iPredicate;
+ public Predicate[] getPredicates() {
+ return new Predicate[] {iPredicate};
}
}
1.1 jakarta-commons/collections/src/java/org/apache/commons/collections/functors/PredicateDecorator.java
Index: PredicateDecorator.java
===================================================================
/*
* Copyright 2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.collections.functors;
import org.apache.commons.collections.Predicate;
/**
* Defines a predicate that decorates one or more other predicates.
* <p>
* This interface enables tools to access the decorated predicates.
*
* @since Commons Collections 3.1
* @version $Revision: 1.1 $ $Date: 2004/05/31 16:43:17 $
*
* @author Stephen Colebourne
*/
public interface PredicateDecorator extends Predicate {
/**
* Gets the predicates being decorated as an array.
* <p>
* The array may be the internal data structure of the predicate and thus
* should not be altered.
*
* @return the predicates being decorated
*/
Predicate[] getPredicates();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
|