You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by rw...@apache.org on 2004/01/05 19:11:36 UTC
cvs commit: jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/generator/util CollectionTransformer.java
rwaldhoff 2004/01/05 10:11:36
Modified: functor/src/java/org/apache/commons/functor/generator
BaseTransformer.java Transformer.java
Generator.java BaseGenerator.java
functor/src/test/org/apache/commons/functor/generator
TestBaseTransformer.java
functor/src/java/org/apache/commons/functor/generator/util
CollectionTransformer.java
Log:
deprecate Transformer, to be replaced by UnaryFunction
Revision Changes Path
1.2 +4 -3 jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/generator/BaseTransformer.java
Index: BaseTransformer.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/generator/BaseTransformer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BaseTransformer.java 25 Nov 2003 19:55:02 -0000 1.1
+++ BaseTransformer.java 5 Jan 2004 18:11:36 -0000 1.2
@@ -3,7 +3,7 @@
* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -61,6 +61,7 @@
* @since 1.0
* @version $Revision$ $Date$
* @author Rodney Waldhoff
+ * @deprecated To be removed.
*/
public abstract class BaseTransformer implements Transformer {
public abstract Object transform(Generator gen);
1.3 +4 -3 jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/generator/Transformer.java
Index: Transformer.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/generator/Transformer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Transformer.java 25 Nov 2003 19:55:02 -0000 1.2
+++ Transformer.java 5 Jan 2004 18:11:36 -0000 1.3
@@ -3,7 +3,7 @@
* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -66,6 +66,7 @@
* @since 1.0
* @version $Revision$ $Date$
* @author Jason Horman (jason@jhorman.org)
+ * @deprecated Simply use UnaryFunction.
*/
public interface Transformer extends UnaryFunction {
1.9 +5 -5 jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/generator/Generator.java
Index: Generator.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/generator/Generator.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Generator.java 2 Dec 2003 01:01:59 -0000 1.8
+++ Generator.java 5 Jan 2004 18:11:36 -0000 1.9
@@ -3,7 +3,7 @@
* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -96,11 +96,11 @@
/** See {@link org.apache.commons.functor.Algorithms#until}. */
public abstract Generator until(UnaryPredicate pred);
/**
- * {@link Transformer Transforms} this generator using the passed in
+ * Transforms this generator using the passed in
* transformer. An example transformer might turn the contents of the
* generator into a {@link Collection} of elements.
*/
- public abstract Object to(Transformer transformer);
+ public abstract Object to(UnaryFunction transformer);
/** Same as to(new CollectionTransformer(collection)). */
public abstract Collection to(Collection collection);
/** Same as to(new CollectionTransformer()). */
1.6 +5 -5 jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/generator/BaseGenerator.java
Index: BaseGenerator.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/generator/BaseGenerator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- BaseGenerator.java 2 Dec 2003 01:01:59 -0000 1.5
+++ BaseGenerator.java 5 Jan 2004 18:11:36 -0000 1.6
@@ -3,7 +3,7 @@
* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -170,8 +170,8 @@
* transformer. An example transformer might turn the contents of the
* generator into a {@link Collection} of elements.
*/
- public final Object to(Transformer transformer) {
- return transformer.transform(this);
+ public final Object to(UnaryFunction transformer) {
+ return transformer.evaluate(this);
}
/** Same as to(new CollectionTransformer(collection)). */
1.2 +4 -3 jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/generator/TestBaseTransformer.java
Index: TestBaseTransformer.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/test/org/apache/commons/functor/generator/TestBaseTransformer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestBaseTransformer.java 25 Nov 2003 19:55:03 -0000 1.1
+++ TestBaseTransformer.java 5 Jan 2004 18:11:36 -0000 1.2
@@ -3,7 +3,7 @@
* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2003-2004 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -64,6 +64,7 @@
/**
* @version $Revision$ $Date$
* @author Rodney Waldhoff
+ * @deprecated BaseTransformer is going to be removed.
*/
public class TestBaseTransformer extends TestCase {
1.4 +14 -16 jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/generator/util/CollectionTransformer.java
Index: CollectionTransformer.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/functor/src/java/org/apache/commons/functor/generator/util/CollectionTransformer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CollectionTransformer.java 25 Nov 2003 19:55:03 -0000 1.3
+++ CollectionTransformer.java 5 Jan 2004 18:11:36 -0000 1.4
@@ -60,8 +60,8 @@
import java.util.ArrayList;
import java.util.Collection;
+import org.apache.commons.functor.UnaryFunction;
import org.apache.commons.functor.UnaryProcedure;
-import org.apache.commons.functor.generator.BaseTransformer;
import org.apache.commons.functor.generator.Generator;
/**
@@ -73,18 +73,14 @@
* @author Jason Horman (jason@jhorman.org)
*/
-public class CollectionTransformer extends BaseTransformer {
-
- /***************************************************
- * Instance variables
- ***************************************************/
+public class CollectionTransformer implements UnaryFunction {
+ // instance methods
+ //---------------------------------------------------
private Collection toFill = null;
- /***************************************************
- * Constructors
- ***************************************************/
-
+ // constructors
+ //---------------------------------------------------
public CollectionTransformer() {
toFill = new ArrayList();
}
@@ -93,11 +89,13 @@
this.toFill = toFill;
}
- /***************************************************
- * Instance methods
- ***************************************************/
+ // instance methods
+ //---------------------------------------------------
+ public Object evaluate(Object obj) {
+ return evaluate((Generator)obj);
+ }
- public Object transform(Generator generator) {
+ public Object evaluate(Generator generator) {
generator.run(new UnaryProcedure() {
public void run(Object obj) {
toFill.add(obj);
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org