You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ki...@apache.org on 2013/07/31 00:48:08 UTC
svn commit: r1508677 [9/9] - in /commons/proper/functor/trunk:
api/src/main/java/org/apache/commons/functor/
core/src/main/java/org/apache/commons/functor/adapter/
core/src/main/java/org/apache/commons/functor/aggregator/
core/src/main/java/org/apache/...
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/FlexiMapExample.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/FlexiMapExample.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/FlexiMapExample.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/FlexiMapExample.java Tue Jul 30 22:48:02 2013
@@ -30,10 +30,10 @@ import java.util.Set;
import org.apache.commons.functor.BinaryFunction;
import org.apache.commons.functor.BinaryProcedure;
+import org.apache.commons.functor.NullaryFunction;
+import org.apache.commons.functor.NullaryProcedure;
import org.apache.commons.functor.Function;
import org.apache.commons.functor.Procedure;
-import org.apache.commons.functor.UnaryFunction;
-import org.apache.commons.functor.UnaryProcedure;
import org.apache.commons.functor.adapter.IgnoreLeftFunction;
import org.apache.commons.functor.core.Constant;
import org.apache.commons.functor.core.Identity;
@@ -550,8 +550,8 @@ public class FlexiMapExample {
*/
private abstract class UniversalFunctor implements
- Procedure, UnaryProcedure<Object>, BinaryProcedure<Object, Object>,
- Function<Object>, UnaryFunction<Object, Object>, BinaryFunction<Object, Object, Object> {
+ NullaryProcedure, Procedure<Object>, BinaryProcedure<Object, Object>,
+ NullaryFunction<Object>, Function<Object, Object>, BinaryFunction<Object, Object, Object> {
public abstract void run();
public void run(Object obj) {
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/QuicksortExample.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/QuicksortExample.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/QuicksortExample.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/QuicksortExample.java Tue Jul 30 22:48:02 2013
@@ -26,12 +26,12 @@ import java.util.List;
import java.util.Random;
import org.apache.commons.functor.BinaryFunction;
-import org.apache.commons.functor.UnaryFunction;
+import org.apache.commons.functor.Function;
import org.apache.commons.functor.core.Constant;
import org.apache.commons.functor.core.collection.IsEmpty;
import org.apache.commons.functor.core.comparator.IsGreaterThanOrEqual;
import org.apache.commons.functor.core.comparator.IsLessThan;
-import org.apache.commons.functor.core.composite.ConditionalUnaryFunction;
+import org.apache.commons.functor.core.composite.ConditionalFunction;
import org.apache.commons.functor.generator.FilteredGenerator;
import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
import org.junit.Test;
@@ -306,7 +306,7 @@ public class QuicksortExample {
*/
/*
- * Our quicksort method will invoke a UnaryFunction named
+ * Our quicksort method will invoke a Function named
* quicksort:
*/
@@ -337,7 +337,7 @@ public class QuicksortExample {
* to transalate this description directly into code:
*/
- private UnaryFunction<Object, Object> quicksort = new ConditionalUnaryFunction<Object, Object>(
+ private Function<Object, Object> quicksort = new ConditionalFunction<Object, Object>(
/* if the list is empty... */
IsEmpty.instance(),
/* ...then return an empty list... */
@@ -386,10 +386,10 @@ public class QuicksortExample {
* First, let's save ourselves some casting and error handling by
* definining some functor sub-types.
*
- * Let ListFunction be a UnaryFunction that operates on Lists:
+ * Let ListFunction be a Function that operates on Lists:
*/
- public abstract class ListFunction implements UnaryFunction<Object, Object> {
+ public abstract class ListFunction implements Function<Object, Object> {
public abstract Object evaluate(List<?> list);
public Object evaluate(Object obj) {
@@ -434,7 +434,7 @@ public class QuicksortExample {
* Given a List, we need to be able to break it into its head:
*/
- private UnaryFunction<Object, Object> head = new ListFunction() {
+ private Function<Object, Object> head = new ListFunction() {
@Override
public Object evaluate(List<?> list) {
return list.get(0);
@@ -444,7 +444,7 @@ public class QuicksortExample {
/*
* and its tail:
*/
- private UnaryFunction<Object, Object> tail = new ListFunction() {
+ private Function<Object, Object> tail = new ListFunction() {
@Override
public Object evaluate(List<?> list) {
return list.size() < 2 ?
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/aggregator/list/OwnFunctionImplementationSample.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/aggregator/list/OwnFunctionImplementationSample.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/aggregator/list/OwnFunctionImplementationSample.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/aggregator/list/OwnFunctionImplementationSample.java Tue Jul 30 22:48:02 2013
@@ -18,7 +18,7 @@ package org.apache.commons.functor.examp
import java.util.List;
-import org.apache.commons.functor.UnaryFunction;
+import org.apache.commons.functor.Function;
import org.apache.commons.functor.aggregator.ArrayListBackedAggregator;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@@ -63,7 +63,7 @@ public class OwnFunctionImplementationSa
* This function returns the index of the first occurrence in the list of
* the given value.
*/
- static class OwnFunction implements UnaryFunction<List<Integer>, Integer> {
+ static class OwnFunction implements Function<List<Integer>, Integer> {
/** Value to find in the list. */
private int valueToFind;
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/aggregator/list/OwnListImplementationSample.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/aggregator/list/OwnListImplementationSample.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/aggregator/list/OwnListImplementationSample.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/aggregator/list/OwnListImplementationSample.java Tue Jul 30 22:48:02 2013
@@ -22,7 +22,7 @@ import static org.junit.Assert.assertNul
import java.util.LinkedList;
import java.util.List;
-import org.apache.commons.functor.UnaryFunction;
+import org.apache.commons.functor.Function;
import org.apache.commons.functor.aggregator.AbstractListBackedAggregator;
import org.apache.commons.functor.aggregator.functions.IntegerSumAggregatorFunction;
import org.junit.Test;
@@ -51,15 +51,15 @@ public class OwnListImplementationSample
* type of parameter stored.
*/
static class CustomListAggregator<T> extends AbstractListBackedAggregator<T> {
- public CustomListAggregator(UnaryFunction<List<T>, T> aggregationFunction) {
+ public CustomListAggregator(Function<List<T>, T> aggregationFunction) {
super(aggregationFunction);
}
- public CustomListAggregator(UnaryFunction<List<T>, T> aggregationFunction, long interval) {
+ public CustomListAggregator(Function<List<T>, T> aggregationFunction, long interval) {
super(aggregationFunction, interval);
}
- public CustomListAggregator(UnaryFunction<List<T>, T> aggregationFunction, long interval,
+ public CustomListAggregator(Function<List<T>, T> aggregationFunction, long interval,
boolean useSharedTimer) {
super(aggregationFunction, interval, useSharedTimer);
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/Abs.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/Abs.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/Abs.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/Abs.java Tue Jul 30 22:48:02 2013
@@ -16,7 +16,7 @@
*/
package org.apache.commons.functor.example.kata.four;
-import org.apache.commons.functor.UnaryFunction;
+import org.apache.commons.functor.Function;
/**
* Evaluates to the absolute Integer value of the Number-valued
@@ -24,7 +24,7 @@ import org.apache.commons.functor.UnaryF
*
* @version $Revision$ $Date$
*/
-public final class Abs implements UnaryFunction<Number, Integer> {
+public final class Abs implements Function<Number, Integer> {
public Integer evaluate(Number num) {
return new Integer(Math.abs(num.intValue()));
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/DataMunger.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/DataMunger.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/DataMunger.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/DataMunger.java Tue Jul 30 22:48:02 2013
@@ -21,8 +21,8 @@ import java.io.InputStreamReader;
import java.io.Reader;
import org.apache.commons.functor.BinaryFunction;
-import org.apache.commons.functor.UnaryFunction;
-import org.apache.commons.functor.adapter.BinaryFunctionUnaryFunction;
+import org.apache.commons.functor.Function;
+import org.apache.commons.functor.adapter.BinaryFunctionFunction;
import org.apache.commons.functor.core.IsNull;
import org.apache.commons.functor.core.LeftIdentity;
import org.apache.commons.functor.core.RightIdentity;
@@ -81,14 +81,14 @@ public class DataMunger {
}
/**
- * A UnaryFunction that returns the absolute value of the difference
+ * A Function that returns the absolute value of the difference
* between the Integers stored in the <i>col1</i> and <i>col2</i>th
* whitespace delimited columns of the input line (a String).
*/
- private static UnaryFunction<String, Integer> absSpread(final int col1, final int col2) {
+ private static Function<String, Integer> absSpread(final int col1, final int col2) {
return Composite.function(
Abs.instance(),
- new BinaryFunctionUnaryFunction<String, Number>(
+ new BinaryFunctionFunction<String, Number>(
Composite.function(
Subtract.instance(),
Composite.function(ToInteger.instance(),NthColumn.instance(col1)),
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/IsInteger.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/IsInteger.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/IsInteger.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/IsInteger.java Tue Jul 30 22:48:02 2013
@@ -16,7 +16,7 @@
*/
package org.apache.commons.functor.example.kata.four;
-import org.apache.commons.functor.UnaryPredicate;
+import org.apache.commons.functor.Predicate;
/**
* Tests to true iff the input object can be converted to
@@ -24,7 +24,7 @@ import org.apache.commons.functor.UnaryP
*
* @version $Revision$ $Date$
*/
-public final class IsInteger implements UnaryPredicate<String> {
+public final class IsInteger implements Predicate<String> {
public boolean test(String obj) {
try {
ToInteger.instance().evaluate(obj);
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/NthColumn.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/NthColumn.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/NthColumn.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/NthColumn.java Tue Jul 30 22:48:02 2013
@@ -18,7 +18,7 @@ package org.apache.commons.functor.examp
import java.util.StringTokenizer;
-import org.apache.commons.functor.UnaryFunction;
+import org.apache.commons.functor.Function;
/**
* Evaluates the input String to extrace the nth whitespace
@@ -26,7 +26,7 @@ import org.apache.commons.functor.UnaryF
*
* @version $Revision$ $Date$
*/
-public final class NthColumn implements UnaryFunction<String, String> {
+public final class NthColumn implements Function<String, String> {
public NthColumn(int n) {
this.n = n;
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/ToInteger.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/ToInteger.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/ToInteger.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/four/ToInteger.java Tue Jul 30 22:48:02 2013
@@ -16,7 +16,7 @@
*/
package org.apache.commons.functor.example.kata.four;
-import org.apache.commons.functor.UnaryFunction;
+import org.apache.commons.functor.Function;
/**
* Converts a String value to an Integer, throwing
@@ -27,7 +27,7 @@ import org.apache.commons.functor.UnaryF
*
* @version $Revision$ $Date$
*/
-public final class ToInteger implements UnaryFunction<String, Integer> {
+public final class ToInteger implements Function<String, Integer> {
public Integer evaluate(String str) {
StringBuffer buf = new StringBuffer();
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Add.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Add.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Add.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Add.java Tue Jul 30 22:48:02 2013
@@ -16,7 +16,7 @@
*/
package org.apache.commons.functor.example.kata.one;
-import org.apache.commons.functor.UnaryFunction;
+import org.apache.commons.functor.Function;
import org.apache.commons.functor.adapter.LeftBoundFunction;
/**
@@ -31,7 +31,7 @@ public class Add extends ArithmeticOpera
return INSTANCE;
}
- public static UnaryFunction<Number, Number> to(int factor) {
+ public static Function<Number, Number> to(int factor) {
return LeftBoundFunction.bind(INSTANCE, factor);
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Divide.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Divide.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Divide.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Divide.java Tue Jul 30 22:48:02 2013
@@ -16,7 +16,7 @@
*/
package org.apache.commons.functor.example.kata.one;
-import org.apache.commons.functor.UnaryFunction;
+import org.apache.commons.functor.Function;
import org.apache.commons.functor.adapter.RightBoundFunction;
/**
@@ -32,7 +32,7 @@ public class Divide extends ArithmeticOp
return INSTANCE;
}
- public static UnaryFunction<Number, Number> by(int factor) {
+ public static Function<Number, Number> by(int factor) {
return RightBoundFunction.bind(INSTANCE, factor);
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Mod.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Mod.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Mod.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Mod.java Tue Jul 30 22:48:02 2013
@@ -16,7 +16,7 @@
*/
package org.apache.commons.functor.example.kata.one;
-import org.apache.commons.functor.UnaryFunction;
+import org.apache.commons.functor.Function;
import org.apache.commons.functor.adapter.RightBoundFunction;
/**
@@ -31,7 +31,7 @@ public class Mod extends ArithmeticOpera
return INSTANCE;
}
- public static UnaryFunction<Number, Number> by(int factor) {
+ public static Function<Number, Number> by(int factor) {
return RightBoundFunction.bind(instance(),factor);
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Multiply.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Multiply.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Multiply.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Multiply.java Tue Jul 30 22:48:02 2013
@@ -16,7 +16,7 @@
*/
package org.apache.commons.functor.example.kata.one;
-import org.apache.commons.functor.UnaryFunction;
+import org.apache.commons.functor.Function;
import org.apache.commons.functor.adapter.LeftBoundFunction;
/**
@@ -32,7 +32,7 @@ public class Multiply extends Arithmetic
return INSTANCE;
}
- public static UnaryFunction<Number, Number> by(int factor) {
+ public static Function<Number, Number> by(int factor) {
return LeftBoundFunction.bind(INSTANCE, factor);
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Product.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Product.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Product.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Product.java Tue Jul 30 22:48:02 2013
@@ -16,7 +16,7 @@
*/
package org.apache.commons.functor.example.kata.one;
-import org.apache.commons.functor.UnaryFunction;
+import org.apache.commons.functor.Function;
/**
@@ -27,7 +27,7 @@ public class Product {
this(name,sku,ToMoney.from(Multiply.by(cost)));
}
- public Product(String name, String sku, UnaryFunction<? super Integer, Money> price) {
+ public Product(String name, String sku, Function<? super Integer, Money> price) {
this.name = name;
this.sku = sku;
this.priceFunction = price;
@@ -37,7 +37,7 @@ public class Product {
return name;
}
- public UnaryFunction<? super Integer, Money> getPriceFunction() {
+ public Function<? super Integer, Money> getPriceFunction() {
return priceFunction;
}
@@ -49,7 +49,7 @@ public class Product {
name = string;
}
- public void setPriceFunction(UnaryFunction<? super Integer, Money> function) {
+ public void setPriceFunction(Function<? super Integer, Money> function) {
priceFunction = function;
}
@@ -63,5 +63,5 @@ public class Product {
private String name;
private String sku;
- private UnaryFunction<? super Integer, Money> priceFunction;
+ private Function<? super Integer, Money> priceFunction;
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Subtract.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Subtract.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Subtract.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/Subtract.java Tue Jul 30 22:48:02 2013
@@ -16,7 +16,7 @@
*/
package org.apache.commons.functor.example.kata.one;
-import org.apache.commons.functor.UnaryFunction;
+import org.apache.commons.functor.Function;
import org.apache.commons.functor.adapter.LeftBoundFunction;
/**
@@ -31,7 +31,7 @@ public class Subtract extends Arithmetic
return INSTANCE;
}
- public static UnaryFunction<Number, Number> from(int factor) {
+ public static Function<Number, Number> from(int factor) {
return LeftBoundFunction.bind(INSTANCE, factor);
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/SupermarketPricingExample.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/SupermarketPricingExample.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/SupermarketPricingExample.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/SupermarketPricingExample.java Tue Jul 30 22:48:02 2013
@@ -18,13 +18,13 @@ package org.apache.commons.functor.examp
import static org.junit.Assert.assertEquals;
-import org.apache.commons.functor.UnaryFunction;
-import org.apache.commons.functor.adapter.BinaryFunctionUnaryFunction;
+import org.apache.commons.functor.Function;
+import org.apache.commons.functor.adapter.BinaryFunctionFunction;
import org.apache.commons.functor.core.Identity;
import org.apache.commons.functor.core.comparator.IsGreaterThan;
import org.apache.commons.functor.core.composite.Composite;
-import org.apache.commons.functor.core.composite.ConditionalUnaryFunction;
-import org.apache.commons.functor.core.composite.UnaryCompositeBinaryFunction;
+import org.apache.commons.functor.core.composite.ConditionalFunction;
+import org.apache.commons.functor.core.composite.CompositeBinaryFunction;
import org.junit.Test;
/**
@@ -121,7 +121,7 @@ public class SupermarketPricingExample {
"Banana",
"SKU-0002",
ToMoney.from(
- new ConditionalUnaryFunction<Integer, Number>(
+ new ConditionalFunction<Integer, Number>(
IsGreaterThan.instance(new Integer(3)),
Multiply.by(25),
Multiply.by(33))));
@@ -144,8 +144,8 @@ public class SupermarketPricingExample {
"Banana",
"SKU-0002",
ToMoney.from(
- new BinaryFunctionUnaryFunction<Integer, Number>(
- new UnaryCompositeBinaryFunction<Integer, Integer, Number>(
+ new BinaryFunctionFunction<Integer, Number>(
+ new CompositeBinaryFunction<Integer, Integer, Number>(
Add.instance(),
Composite.function(
Multiply.by(100),
@@ -182,7 +182,7 @@ public class SupermarketPricingExample {
"SKU-0003",
ToMoney.from(
Composite.function(Multiply.by(40),
- BinaryFunctionUnaryFunction.adapt(new UnaryCompositeBinaryFunction<Number, Number, Number>(Subtract.instance(),
+ BinaryFunctionFunction.adapt(new CompositeBinaryFunction<Number, Number, Number>(Subtract.instance(),
new Identity<Number>(),
Divide.by(3))))));
@@ -204,11 +204,11 @@ public class SupermarketPricingExample {
* and we haven't even considered things
* something like "buy 3, get 2 free", etc.
*
- * Perhaps a special UnaryFunction instance is in
+ * Perhaps a special Function instance is in
* order:
*/
- class BuyNGetMFree implements UnaryFunction<Number, Number> {
+ class BuyNGetMFree implements Function<Number, Number> {
public BuyNGetMFree(int n, int m, int costPerUnit) {
this.n = n;
this.m = m;
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/ToMoney.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/ToMoney.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/ToMoney.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/one/ToMoney.java Tue Jul 30 22:48:02 2013
@@ -16,13 +16,13 @@
*/
package org.apache.commons.functor.example.kata.one;
-import org.apache.commons.functor.UnaryFunction;
+import org.apache.commons.functor.Function;
import org.apache.commons.functor.core.composite.Composite;
/**
* @version $Revision$ $Date$
*/
-public class ToMoney implements UnaryFunction<Number, Money> {
+public class ToMoney implements Function<Number, Money> {
public Money evaluate(Number cents) {
return new Money(cents.intValue());
@@ -32,7 +32,7 @@ public class ToMoney implements UnaryFun
return INSTANCE;
}
- public static <X> UnaryFunction<X, Money> from(UnaryFunction<? super X, ? extends Number> fn) {
+ public static <X> Function<X, Money> from(Function<? super X, ? extends Number> fn) {
return Composite.function(INSTANCE, fn);
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/two/EiffelStyleLoop.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/two/EiffelStyleLoop.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/two/EiffelStyleLoop.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/two/EiffelStyleLoop.java Tue Jul 30 22:48:02 2013
@@ -16,9 +16,9 @@
*/
package org.apache.commons.functor.example.kata.two;
-import org.apache.commons.functor.Function;
-import org.apache.commons.functor.Predicate;
-import org.apache.commons.functor.Procedure;
+import org.apache.commons.functor.NullaryFunction;
+import org.apache.commons.functor.NullaryPredicate;
+import org.apache.commons.functor.NullaryProcedure;
import org.apache.commons.functor.core.Constant;
import org.apache.commons.functor.core.NoOp;
@@ -26,13 +26,13 @@ import org.apache.commons.functor.core.N
* Supports an Eiffel style loop construct.
* <pre>
* new EiffelStyleLoop()
- * .from(new Procedure() { public void run() {} }) // init code
- * .invariant(new Predicate() { public boolean test() {} }) // invariants
- * .variant(new Procedure() { public Object evaluate() {} }) // diminishing comparable value
+ * .from(new NullaryProcedure() { public void run() {} }) // init code
+ * .invariant(new NullaryPredicate() { public boolean test() {} }) // invariants
+ * .variant(new NullaryProcedure() { public Object evaluate() {} }) // diminishing comparable value
* // or
- * // .variant(new Predicate() { public boolean test() {} }) // more invariants
- * .until(new Predicate() { public boolean test() {} }) // terminating condition
- * .loop(new Procedure() { public void run() {} }) // the acutal loop
+ * // .variant(new NullaryPredicate() { public boolean test() {} }) // more invariants
+ * .until(new NullaryPredicate() { public boolean test() {} }) // terminating condition
+ * .loop(new NullaryProcedure() { public void run() {} }) // the acutal loop
* .run();
* </pre>
*
@@ -41,25 +41,25 @@ import org.apache.commons.functor.core.N
*
* @version $Revision$ $Date$
*/
-public class EiffelStyleLoop implements Procedure {
- public EiffelStyleLoop from(Procedure procedure) {
+public class EiffelStyleLoop implements NullaryProcedure {
+ public EiffelStyleLoop from(NullaryProcedure procedure) {
from = procedure;
return this;
}
- public EiffelStyleLoop invariant(Predicate predicate) {
+ public EiffelStyleLoop invariant(NullaryPredicate predicate) {
invariant = predicate;
return this;
}
- public EiffelStyleLoop variant(Predicate predicate) {
+ public EiffelStyleLoop variant(NullaryPredicate predicate) {
variant = predicate;
return this;
}
@SuppressWarnings("unchecked")
- public EiffelStyleLoop variant(final Function<Object> function) {
- return variant(new Predicate() {
+ public EiffelStyleLoop variant(final NullaryFunction<Object> function) {
+ return variant(new NullaryPredicate() {
public boolean test() {
boolean result = true;
Comparable<Object> next = (Comparable<Object>)(function.evaluate());
@@ -73,12 +73,12 @@ public class EiffelStyleLoop implements
});
}
- public EiffelStyleLoop until(Predicate predicate) {
+ public EiffelStyleLoop until(NullaryPredicate predicate) {
until = predicate;
return this;
}
- public EiffelStyleLoop loop(Procedure procedure) {
+ public EiffelStyleLoop loop(NullaryProcedure procedure) {
loop = procedure;
return this;
}
@@ -109,10 +109,10 @@ public class EiffelStyleLoop implements
}
}
- private Procedure from = NoOp.instance();
- private Predicate invariant = Constant.truePredicate();
- private Predicate variant = Constant.truePredicate();
- private Predicate until = Constant.falsePredicate();
- private Procedure loop = NoOp.instance();
+ private NullaryProcedure from = NoOp.instance();
+ private NullaryPredicate invariant = Constant.truePredicate();
+ private NullaryPredicate variant = Constant.truePredicate();
+ private NullaryPredicate until = Constant.falsePredicate();
+ private NullaryProcedure loop = NoOp.instance();
}
\ No newline at end of file
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/kata/two/TestBinaryChop.java Tue Jul 30 22:48:02 2013
@@ -21,9 +21,9 @@ import static org.junit.Assert.assertEqu
import java.util.Collections;
import java.util.List;
-import org.apache.commons.functor.Function;
-import org.apache.commons.functor.Predicate;
-import org.apache.commons.functor.Procedure;
+import org.apache.commons.functor.NullaryFunction;
+import org.apache.commons.functor.NullaryPredicate;
+import org.apache.commons.functor.NullaryProcedure;
import org.apache.commons.functor.core.algorithm.RecursiveEvaluation;
import org.apache.commons.functor.core.algorithm.UntilDo;
import org.apache.commons.functor.generator.util.IntegerRange;
@@ -209,7 +209,7 @@ public class TestBinaryChop {
* // the result index is between
* // low (inclusive) and high (exclusive),
* // or high is 0 (the list is empty)
- * Predicate INV = new Predicate() {
+ * NullaryPredicate INV = new NullaryPredicate() {
* public boolean test() {
* return high == 0 ||
* (low <= result && result < high);
@@ -218,7 +218,7 @@ public class TestBinaryChop {
*
* is a valid invariant in our binary search, and that:
*
- * Predicate TERM = new Predicate() {
+ * NullaryPredicate TERM = new NullaryPredicate() {
* public boolean test() {
* return (high - low) <= 1;
* }
@@ -230,7 +230,7 @@ public class TestBinaryChop {
* closer together, without violating
* our invariant:
*
- * Procedure BODY = new Procedure() {
+ * NullaryProcedure BODY = new NullaryProcedure() {
* public void run() {
* int mid = (high + low) / 2;
* if (greaterThan(list,mid,seeking)) {
@@ -252,12 +252,12 @@ public class TestBinaryChop {
* Algorithms.untildo(BODY,TERM);
*
* Since we'll want to share state among the TERM and BODY,
- * let's declare a single interface for the TERM Predicate and
- * the BODY Procedure. We'll be calculating a result within
- * the loop, so let's add a Function implementation as well,
+ * let's declare a single interface for the TERM NullaryPredicate and
+ * the BODY NullaryProcedure. We'll be calculating a result within
+ * the loop, so let's add a NullaryFunction implementation as well,
* as a way of retrieving that result:
*/
- interface Loop extends Predicate, Procedure, Function<Object> {
+ interface Loop extends NullaryPredicate, NullaryProcedure, NullaryFunction<Object> {
/** The terminating condition. */
boolean test();
/** The loop body. */
@@ -341,32 +341,32 @@ public class TestBinaryChop {
seeking = aSeeking;
list = aList;
- from(new Procedure() {
+ from(new NullaryProcedure() {
public void run() {
low = 0;
high = list.size();
}
});
- invariant(new Predicate() {
+ invariant(new NullaryPredicate() {
public boolean test() {
return high == 0 || low < high;
}
});
- variant(new Function<Object>() {
+ variant(new NullaryFunction<Object>() {
public Object evaluate() {
return new Integer(high - low);
}
});
- until(new Predicate() {
+ until(new NullaryPredicate() {
public boolean test() {
return high - low <= 1;
}
});
- loop(new Procedure() {
+ loop(new NullaryProcedure() {
public void run() {
int mid = (high + low) / 2;
if (BaseBinaryChop.greaterThan(list,mid,seeking)) {
@@ -429,7 +429,7 @@ public class TestBinaryChop {
* We can use the Algorithms.recuse method
* to implement that as tail recursion.
*
- * Here the anonymous Function implemenation
+ * Here the anonymous NullaryFunction implemenation
* holds this itermediate state, rather than
* the VM's call stack.
*
@@ -441,7 +441,7 @@ public class TestBinaryChop {
public void testTailRecursive() {
chopTest(new BaseBinaryChop() {
public int find(final Integer seeking, final List<Integer> list) {
- return ((Number) new RecursiveEvaluation(new Function<Object>() {
+ return ((Number) new RecursiveEvaluation(new NullaryFunction<Object>() {
public Object evaluate() {
if (high - low > 1) {
int mid = (high + low) / 2;
@@ -510,14 +510,14 @@ public class TestBinaryChop {
/**
* We can do that using tail recursion as well.
*
- * Again, the anonymous Function implemenation
+ * Again, the anonymous NullaryFunction implemenation
* holds the "continuation" state.
*/
@Test
public void testTailRecursive2() {
chopTest(new BaseBinaryChop() {
public int find(final Integer seeking, final List<Integer> list) {
- return ((Number) new RecursiveEvaluation(new Function<Object>() {
+ return ((Number) new RecursiveEvaluation(new NullaryFunction<Object>() {
public Object evaluate() {
if (sublist.isEmpty()) {
return BaseBinaryChop.NEGATIVE_ONE;
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/Contains.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/Contains.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/Contains.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/Contains.java Tue Jul 30 22:48:02 2013
@@ -16,13 +16,13 @@
*/
package org.apache.commons.functor.example.lines;
-import org.apache.commons.functor.UnaryPredicate;
+import org.apache.commons.functor.Predicate;
/**
* @version $Revision$ $Date$
*/
-public class Contains<T> implements UnaryPredicate<T> {
+public class Contains<T> implements Predicate<T> {
public Contains(String str) {
this.str = str;
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/Count.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/Count.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/Count.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/Count.java Tue Jul 30 22:48:02 2013
@@ -16,12 +16,12 @@
*/
package org.apache.commons.functor.example.lines;
-import org.apache.commons.functor.Procedure;
+import org.apache.commons.functor.NullaryProcedure;
/**
* @version $Revision$ $Date$
*/
-public class Count implements Procedure {
+public class Count implements NullaryProcedure {
public void run() {
count++;
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/Lines.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/Lines.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/Lines.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/Lines.java Tue Jul 30 22:48:02 2013
@@ -22,7 +22,7 @@ import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.Reader;
-import org.apache.commons.functor.UnaryProcedure;
+import org.apache.commons.functor.Procedure;
import org.apache.commons.functor.generator.BaseGenerator;
/**
@@ -45,7 +45,7 @@ public class Lines extends BaseGenerator
}
}
- public void run(UnaryProcedure<? super String> proc) {
+ public void run(Procedure<? super String> proc) {
try {
for (String line = in.readLine(); line != null; line = in.readLine()) {
proc.run(line);
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/StartsWith.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/StartsWith.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/StartsWith.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/StartsWith.java Tue Jul 30 22:48:02 2013
@@ -16,13 +16,13 @@
*/
package org.apache.commons.functor.example.lines;
-import org.apache.commons.functor.UnaryPredicate;
+import org.apache.commons.functor.Predicate;
/**
* @version $Revision$ $Date$
*/
-public class StartsWith<T> implements UnaryPredicate<T> {
+public class StartsWith<T> implements Predicate<T> {
public StartsWith(String prefix) {
this.prefix = prefix;
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/TestLines.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/TestLines.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/TestLines.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/TestLines.java Tue Jul 30 22:48:02 2013
@@ -24,12 +24,12 @@ import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.apache.commons.functor.adapter.ProcedureUnaryProcedure;
+import org.apache.commons.functor.adapter.NullaryProcedureProcedure;
import org.apache.commons.functor.core.Offset;
import org.apache.commons.functor.core.algorithm.FoldLeft;
import org.apache.commons.functor.core.collection.Size;
-import org.apache.commons.functor.core.composite.UnaryAnd;
-import org.apache.commons.functor.core.composite.UnaryNot;
+import org.apache.commons.functor.core.composite.And;
+import org.apache.commons.functor.core.composite.Not;
import org.apache.commons.functor.generator.FilteredGenerator;
import org.apache.commons.functor.generator.TransformedGenerator;
@@ -78,14 +78,14 @@ public class TestLines extends TestCase
Count count = new Count();
Lines
.from(reader)
- .run(ProcedureUnaryProcedure.adapt(count));
+ .run(NullaryProcedureProcedure.adapt(count));
assertEquals("Expected 16 lines",16,count.getCount());
}
public void testCountWordsExcludingComments() throws Exception {
Object result = new FoldLeft<Integer>(Sum.instance()).evaluate(new TransformedGenerator<String, Integer>(
- new FilteredGenerator<String>(Lines.from(reader), UnaryNot.not(new StartsWith<String>("#"))), WordCount
+ new FilteredGenerator<String>(Lines.from(reader), Not.not(new StartsWith<String>("#"))), WordCount
.instance()));
assertEquals("Expected 90 words",new Integer(90),result);
@@ -94,7 +94,7 @@ public class TestLines extends TestCase
public void testCountCommentLines() throws Exception {
Count count = new Count();
new FilteredGenerator<String>(Lines.from(reader), new StartsWith<String>("#"))
- .run(ProcedureUnaryProcedure.<String>adapt(count));
+ .run(NullaryProcedureProcedure.<String>adapt(count));
assertEquals("Expected 6 lines",6,count.getCount());
}
@@ -107,7 +107,7 @@ public class TestLines extends TestCase
@SuppressWarnings("unchecked")
public void testFindMatchingFromTail() throws Exception {
- Collection<String> matches = new FilteredGenerator<String>(Lines.from(reader), new UnaryAnd<String>(new Offset(
+ Collection<String> matches = new FilteredGenerator<String>(Lines.from(reader), new And<String>(new Offset(
8), new Contains<String>("lo"))).toCollection();
assertEquals("Expected 2 lines",2,matches.size());
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/WordCount.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/WordCount.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/WordCount.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/lines/WordCount.java Tue Jul 30 22:48:02 2013
@@ -18,12 +18,12 @@ package org.apache.commons.functor.examp
import java.util.StringTokenizer;
-import org.apache.commons.functor.UnaryFunction;
+import org.apache.commons.functor.Function;
/**
* @version $Revision$ $Date$
*/
-public class WordCount implements UnaryFunction<String, Integer> {
+public class WordCount implements Function<String, Integer> {
public Integer evaluate(String obj) {
return new StringTokenizer(obj).countTokens();
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/FixedSizeMap.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/FixedSizeMap.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/FixedSizeMap.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/FixedSizeMap.java Tue Jul 30 22:48:02 2013
@@ -23,7 +23,7 @@ import org.apache.commons.functor.Binary
import org.apache.commons.functor.BinaryProcedure;
import org.apache.commons.functor.adapter.BinaryProcedureBinaryFunction;
import org.apache.commons.functor.core.algorithm.GeneratorContains;
-import org.apache.commons.functor.core.composite.UnaryNot;
+import org.apache.commons.functor.core.composite.Not;
import org.apache.commons.functor.generator.IteratorToGeneratorAdapter;
/**
@@ -50,7 +50,7 @@ public class FixedSizeMap<K, V> extends
Map<K,V> dest = a;
Map<K,V> src = b;
- if (GeneratorContains.instance().test(IteratorToGeneratorAdapter.adapt(src.keySet().iterator()),UnaryNot.not(new ContainsKey(dest)))) {
+ if (GeneratorContains.instance().test(IteratorToGeneratorAdapter.adapt(src.keySet().iterator()),Not.not(new ContainsKey(dest)))) {
throw new IllegalArgumentException();
} else {
dest.putAll(src);
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/FunctoredMap.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/FunctoredMap.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/FunctoredMap.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/FunctoredMap.java Tue Jul 30 22:48:02 2013
@@ -23,9 +23,9 @@ import java.util.Set;
import org.apache.commons.functor.BinaryFunction;
import org.apache.commons.functor.BinaryProcedure;
+import org.apache.commons.functor.NullaryProcedure;
+import org.apache.commons.functor.Predicate;
import org.apache.commons.functor.Procedure;
-import org.apache.commons.functor.UnaryPredicate;
-import org.apache.commons.functor.UnaryProcedure;
/**
* @version $Revision$ $Date$
@@ -101,7 +101,7 @@ public class FunctoredMap<K, V> implemen
// protected
- protected void setOnClear(UnaryProcedure<Map<K, V>> procedure) {
+ protected void setOnClear(Procedure<Map<K, V>> procedure) {
onclear = procedure;
}
@@ -161,19 +161,19 @@ public class FunctoredMap<K, V> implemen
private BinaryFunction<Map<K, V>, K, V> onremove = DEFAULT_ON_REMOVE;
- protected UnaryProcedure<Map<K, V>> DEFAULT_ON_CLEAR = new UnaryProcedure<Map<K, V>>() {
+ protected Procedure<Map<K, V>> DEFAULT_ON_CLEAR = new Procedure<Map<K, V>>() {
public void run(Map<K, V> map) {
map.clear();
}
};
- private UnaryProcedure<Map<K, V>> onclear = DEFAULT_ON_CLEAR;
+ private Procedure<Map<K, V>> onclear = DEFAULT_ON_CLEAR;
private Map<K, V> map = null;
// inner classes
- protected static class ContainsKey implements UnaryPredicate<Object> {
+ protected static class ContainsKey implements Predicate<Object> {
ContainsKey(Map<?, ?> map) {
this.map = map;
}
@@ -185,7 +185,7 @@ public class FunctoredMap<K, V> implemen
private Map<?, ?> map = null;
}
- protected static class Throw<K, V> implements Procedure, UnaryProcedure<Map<K, V>>, BinaryProcedure<K, V> {
+ protected static class Throw<K, V> implements NullaryProcedure, Procedure<Map<K, V>>, BinaryProcedure<K, V> {
Throw(RuntimeException e) {
this.klass = e.getClass();
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/LazyMap.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/LazyMap.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/LazyMap.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/LazyMap.java Tue Jul 30 22:48:02 2013
@@ -19,13 +19,13 @@ package org.apache.commons.functor.examp
import java.util.Map;
import org.apache.commons.functor.BinaryFunction;
-import org.apache.commons.functor.UnaryFunction;
+import org.apache.commons.functor.Function;
/**
* @version $Revision$ $Date$
*/
public class LazyMap<K, V> extends FunctoredMap<K, V> {
- public LazyMap(Map<K, V> map, final UnaryFunction<K, V> factory) {
+ public LazyMap(Map<K, V> map, final Function<K, V> factory) {
super(map);
setOnGet(new BinaryFunction<Map<K,V>, K, V>() {
public V evaluate(Map<K, V> map, K key) {
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/PredicatedMap.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/PredicatedMap.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/PredicatedMap.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/example/map/PredicatedMap.java Tue Jul 30 22:48:02 2013
@@ -22,7 +22,7 @@ import java.util.Map;
import org.apache.commons.functor.BinaryPredicate;
import org.apache.commons.functor.BinaryProcedure;
-import org.apache.commons.functor.UnaryPredicate;
+import org.apache.commons.functor.Predicate;
import org.apache.commons.functor.adapter.BinaryProcedureBinaryFunction;
import org.apache.commons.functor.core.composite.ConditionalBinaryFunction;
@@ -30,7 +30,7 @@ import org.apache.commons.functor.core.c
* @version $Revision$ $Date$
*/
public class PredicatedMap<K, V> extends FunctoredMap<K, V> {
- public PredicatedMap(Map<K, V> map, final UnaryPredicate<K> keyPredicate, final UnaryPredicate<V> valuePredicate) {
+ public PredicatedMap(Map<K, V> map, final Predicate<K> keyPredicate, final Predicate<V> valuePredicate) {
super(map);
setOnPut(new ConditionalBinaryFunction<Map<K,V>, Object[], V>(
new BinaryPredicate<Map<K, V>, Object[]>() {
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java Tue Jul 30 22:48:02 2013
@@ -24,7 +24,7 @@ import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
-import org.apache.commons.functor.UnaryProcedure;
+import org.apache.commons.functor.Procedure;
import org.apache.commons.functor.generator.util.CollectionTransformer;
import org.junit.After;
import org.junit.Before;
@@ -44,7 +44,7 @@ public class TestBaseGenerator {
@Before
public void setUp() throws Exception {
simpleGenerator = new BaseGenerator<Integer>() {
- public void run(UnaryProcedure<? super Integer> proc) {
+ public void run(Procedure<? super Integer> proc) {
for (int i=0;i<5;i++) {
proc.run(new Integer(i));
if (isStopped()) {
@@ -86,7 +86,7 @@ public class TestBaseGenerator {
@Test
public void testSimpleGenerator() {
final StringBuffer result = new StringBuffer();
- simpleGenerator.run(new UnaryProcedure<Integer>() {
+ simpleGenerator.run(new Procedure<Integer>() {
public void run(Integer obj) {
result.append(obj);
}
@@ -98,7 +98,7 @@ public class TestBaseGenerator {
@Test
public void testStop() {
final StringBuffer result = new StringBuffer();
- simpleGenerator.run(new UnaryProcedure<Integer>() {
+ simpleGenerator.run(new Procedure<Integer>() {
int i=0;
public void run(Integer obj) {
result.append(obj);
@@ -115,10 +115,10 @@ public class TestBaseGenerator {
public void testWrappingGenerator() {
final StringBuffer result = new StringBuffer();
final Generator<Integer> gen = new BaseGenerator<Integer>(simpleGenerator) {
- public void run(final UnaryProcedure<? super Integer> proc) {
+ public void run(final Procedure<? super Integer> proc) {
Generator<Integer> wrapped = (Generator<Integer>)getWrappedGenerator();
assertSame(simpleGenerator, wrapped);
- wrapped.run(new UnaryProcedure<Integer>() {
+ wrapped.run(new Procedure<Integer>() {
public void run(Integer obj) {
proc.run(new Integer(obj.intValue() + 1));
}
@@ -126,7 +126,7 @@ public class TestBaseGenerator {
}
};
- gen.run(new UnaryProcedure<Integer>() {
+ gen.run(new Procedure<Integer>() {
public void run(Integer obj) {
result.append(obj);
}
@@ -136,7 +136,7 @@ public class TestBaseGenerator {
// try to stop the wrapped generator
final StringBuffer result2 = new StringBuffer();
- gen.run(new UnaryProcedure<Integer>() {
+ gen.run(new Procedure<Integer>() {
int i=0;
public void run(Integer obj) {
result2.append(obj);
@@ -180,14 +180,14 @@ public class TestBaseGenerator {
private List<Integer> listWithDuplicates = null;
@SuppressWarnings("unused")
private int sum = 0;
-// private UnaryPredicate equalsThree = LeftBoundPredicate.bind(IsEqual.instance(),new Integer(3));
-// private UnaryPredicate equalsTwentyThree = LeftBoundPredicate.bind(IsEqual.instance(),new Integer(23));
-// private UnaryPredicate isEven = new UnaryPredicate() {
+// private Predicate equalsThree = LeftBoundPredicate.bind(IsEqual.instance(),new Integer(3));
+// private Predicate equalsTwentyThree = LeftBoundPredicate.bind(IsEqual.instance(),new Integer(23));
+// private Predicate isEven = new Predicate() {
// public boolean test(Object obj) {
// return ((Number) obj).intValue() % 2 == 0;
// }
// };
-// private UnaryPredicate isOdd = new UnaryPredicate() {
+// private Predicate isOdd = new Predicate() {
// public boolean test(Object obj) {
// return ((Number) obj).intValue() % 2 != 0;
// }
@@ -196,7 +196,7 @@ public class TestBaseGenerator {
// Classes
// ------------------------------------------------------------------------
- static class Summer implements UnaryProcedure<Number> {
+ static class Summer implements Procedure<Number> {
public void run(Number that) {
sum += (that).intValue();
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestFilteredGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestFilteredGenerator.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestFilteredGenerator.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestFilteredGenerator.java Tue Jul 30 22:48:02 2013
@@ -23,8 +23,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.apache.commons.functor.UnaryPredicate;
-import org.apache.commons.functor.UnaryProcedure;
+import org.apache.commons.functor.Predicate;
+import org.apache.commons.functor.Procedure;
import org.apache.commons.functor.generator.util.IntegerRange;
import org.junit.After;
import org.junit.Before;
@@ -54,7 +54,7 @@ public class TestFilteredGenerator
// ------------------------------------------------------------------------
@Test(expected=NullPointerException.class)
- public void testConstructorProhibitsNullUnaryPredicate() {
+ public void testConstructorProhibitsNullPredicate() {
new FilteredGenerator<Integer>(filteredGenerator, null);
}
@@ -64,7 +64,7 @@ public class TestFilteredGenerator
}
@Test(expected=NullPointerException.class)
- public void testConstructorProhibitsNullUnaryPredicateOrNullWrappedGenerator() {
+ public void testConstructorProhibitsNullPredicateOrNullWrappedGenerator() {
new FilteredGenerator<Integer>(null, null);
}
@@ -76,7 +76,7 @@ public class TestFilteredGenerator
assertTrue(!filteredGenerator.equals((FilteredGenerator<Integer>)null));
Generator<Integer> aGenerateWithADifferentPredicate = new FilteredGenerator<Integer>(
- new IntegerRange(1, 10), new UnaryPredicate<Integer>() {
+ new IntegerRange(1, 10), new Predicate<Integer>() {
public boolean test(Integer obj) {
return obj % 2 == 0;
}
@@ -97,7 +97,7 @@ public class TestFilteredGenerator
@Test
public void testGenerate() {
final List<Integer> evenNumbers = new ArrayList<Integer>();
- filteredGenerator.run(new UnaryProcedure<Integer>() {
+ filteredGenerator.run(new Procedure<Integer>() {
public void run(Integer obj) {
evenNumbers.add(obj);
}
@@ -111,7 +111,7 @@ public class TestFilteredGenerator
// Attributes
// ------------------------------------------------------------------------
private Generator<Integer> wrappedGenerator = null;
- private UnaryPredicate<Integer> isEven = new UnaryPredicate<Integer>()
+ private Predicate<Integer> isEven = new Predicate<Integer>()
{
public boolean test( Integer obj ) {
return obj % 2 == 0;
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestGenerateUntil.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestGenerateUntil.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestGenerateUntil.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestGenerateUntil.java Tue Jul 30 22:48:02 2013
@@ -19,7 +19,7 @@ package org.apache.commons.functor.gener
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import org.apache.commons.functor.UnaryPredicate;
+import org.apache.commons.functor.Predicate;
import org.apache.commons.functor.generator.util.IntegerRange;
import org.junit.After;
import org.junit.Before;
@@ -72,7 +72,7 @@ public class TestGenerateUntil
Generator<Integer> aGenerateWithADifferentPredicate = new GenerateUntil<Integer>(
new IntegerRange(1, 10),
- new UnaryPredicate<Integer>() {
+ new Predicate<Integer>() {
public boolean test(Integer obj) {
return obj > FIVE;
}
@@ -94,7 +94,7 @@ public class TestGenerateUntil
private static final Integer FIVE = new Integer(5);
private Generator<Integer> wrappedGenerator = null;
- private UnaryPredicate<Integer> isMoreThanFive = new UnaryPredicate<Integer>() {
+ private Predicate<Integer> isMoreThanFive = new Predicate<Integer>() {
public boolean test( Integer obj ) {
return obj > FIVE;
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestGenerateWhile.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestGenerateWhile.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestGenerateWhile.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestGenerateWhile.java Tue Jul 30 22:48:02 2013
@@ -19,7 +19,7 @@ package org.apache.commons.functor.gener
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import org.apache.commons.functor.UnaryPredicate;
+import org.apache.commons.functor.Predicate;
import org.apache.commons.functor.generator.util.IntegerRange;
import org.junit.After;
import org.junit.Before;
@@ -49,7 +49,7 @@ public class TestGenerateWhile
// ------------------------------------------------------------------------
@Test(expected=NullPointerException.class)
- public void testConstructorProhibitsNullUnaryPredicate() {
+ public void testConstructorProhibitsNullPredicate() {
new GenerateWhile<Integer>(generateWhile, null);
}
@@ -59,7 +59,7 @@ public class TestGenerateWhile
}
@Test(expected=NullPointerException.class)
- public void testConstructorProhibitsNullUnaryPredicateOrNullWrappedGenerator() {
+ public void testConstructorProhibitsNullPredicateOrNullWrappedGenerator() {
new GenerateWhile<Integer>(null, null);
}
@@ -71,7 +71,7 @@ public class TestGenerateWhile
assertTrue(!generateWhile.equals((GenerateWhile<Integer>)null));
Generator<Integer> aGenerateWithADifferentPredicate = new GenerateWhile<Integer>(
- new IntegerRange(1, 10), new UnaryPredicate<Integer>() {
+ new IntegerRange(1, 10), new Predicate<Integer>() {
public boolean test(Integer obj) {
return obj < FIVE;
}
@@ -94,7 +94,7 @@ public class TestGenerateWhile
private static final Integer FIVE = new Integer(5);
private Generator<Integer> wrappedGenerator = null;
- private UnaryPredicate<Integer> isLessThanFive = new UnaryPredicate<Integer>()
+ private Predicate<Integer> isLessThanFive = new Predicate<Integer>()
{
public boolean test( Integer obj ) {
return obj < FIVE;
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestTransformedGenerator.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestTransformedGenerator.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestTransformedGenerator.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestTransformedGenerator.java Tue Jul 30 22:48:02 2013
@@ -20,8 +20,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.apache.commons.functor.UnaryFunction;
-import org.apache.commons.functor.UnaryProcedure;
+import org.apache.commons.functor.Function;
+import org.apache.commons.functor.Procedure;
import org.apache.commons.functor.generator.util.IntegerRange;
import org.junit.After;
import org.junit.Before;
@@ -56,12 +56,12 @@ public class TestTransformedGenerator
}
@Test(expected=NullPointerException.class)
- public void testConstructorProhibitsNullUnaryFunction() {
+ public void testConstructorProhibitsNullFunction() {
new TransformedGenerator<Integer, Integer>(wrappedGenerator, null);
}
@Test(expected=NullPointerException.class)
- public void testConstructorProhibitsNullWrappedGeneratorOrNullUnaryFunction() {
+ public void testConstructorProhibitsNullWrappedGeneratorOrNullFunction() {
new TransformedGenerator<Integer, Integer>(null, null);
}
@@ -74,7 +74,7 @@ public class TestTransformedGenerator
assertTrue(!sumsTwoGenerator.equals((TransformedGenerator<Integer, Integer>)null));
TransformedGenerator<Integer, Integer> aGenerateWithADifferentFunction =
- new TransformedGenerator<Integer, Integer>(wrappedGenerator, new UnaryFunction<Integer, Integer>() {
+ new TransformedGenerator<Integer, Integer>(wrappedGenerator, new Function<Integer, Integer>() {
public Integer evaluate( Integer obj ) {
return obj;
}
@@ -95,7 +95,7 @@ public class TestTransformedGenerator
@Test
public void testGenerate() {
final List<Integer> doubledValues = new ArrayList<Integer>();
- sumsTwoGenerator.run(new UnaryProcedure<Integer>() {
+ sumsTwoGenerator.run(new Procedure<Integer>() {
public void run( Integer obj ) {
doubledValues.add(obj);
}
@@ -112,7 +112,7 @@ public class TestTransformedGenerator
private static final Integer TWO = new Integer(2);
private Generator<Integer> wrappedGenerator = null;
- private UnaryFunction<Integer, Integer> sumsTwo = new UnaryFunction<Integer, Integer>() {
+ private Function<Integer, Integer> sumsTwo = new Function<Integer, Integer>() {
public Integer evaluate( Integer obj ) {
return obj += TWO;
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestUntilGenerate.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestUntilGenerate.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestUntilGenerate.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestUntilGenerate.java Tue Jul 30 22:48:02 2013
@@ -23,8 +23,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.apache.commons.functor.UnaryPredicate;
-import org.apache.commons.functor.UnaryProcedure;
+import org.apache.commons.functor.Predicate;
+import org.apache.commons.functor.Procedure;
import org.apache.commons.functor.generator.util.IntegerRange;
import org.junit.After;
import org.junit.Before;
@@ -54,7 +54,7 @@ public class TestUntilGenerate
// ------------------------------------------------------------------------
@Test(expected=NullPointerException.class)
- public void testConstructorProhibitsNullUnaryPredicate() {
+ public void testConstructorProhibitsNullPredicate() {
new UntilGenerate<Integer>(null, untilGenerate);
}
@@ -64,7 +64,7 @@ public class TestUntilGenerate
}
@Test(expected=NullPointerException.class)
- public void testConstructorProhibitsNullUnaryPredicateOrNullWrappedGenerator() {
+ public void testConstructorProhibitsNullPredicateOrNullWrappedGenerator() {
new UntilGenerate<Integer>(null, null);
}
@@ -76,7 +76,7 @@ public class TestUntilGenerate
assertTrue(!untilGenerate.equals((UntilGenerate<Integer>)null));
Generator<Integer> aGenerateWithADifferentPredicate = new UntilGenerate<Integer>(
- new UnaryPredicate<Integer>() {
+ new Predicate<Integer>() {
public boolean test(Integer obj) {
return obj < FIVE;
}
@@ -96,7 +96,7 @@ public class TestUntilGenerate
@Test
public void testGenerate() {
final List<Integer> numbersGreaterThanFive = new ArrayList<Integer>();
- untilGenerate.run(new UnaryProcedure<Integer>() {
+ untilGenerate.run(new Procedure<Integer>() {
public void run( Integer obj ) {
numbersGreaterThanFive.add(obj);
}
@@ -112,7 +112,7 @@ public class TestUntilGenerate
private static final Integer FIVE = new Integer(5);
private Generator<Integer> wrappedGenerator = null;
- private UnaryPredicate<Integer> isLessThanFive = new UnaryPredicate<Integer>() {
+ private Predicate<Integer> isLessThanFive = new Predicate<Integer>() {
public boolean test( Integer obj ) {
return obj < FIVE;
}
Modified: commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestWhileGenerate.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestWhileGenerate.java?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestWhileGenerate.java (original)
+++ commons/proper/functor/trunk/core/src/test/java/org/apache/commons/functor/generator/TestWhileGenerate.java Tue Jul 30 22:48:02 2013
@@ -23,8 +23,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.apache.commons.functor.UnaryPredicate;
-import org.apache.commons.functor.UnaryProcedure;
+import org.apache.commons.functor.Predicate;
+import org.apache.commons.functor.Procedure;
import org.apache.commons.functor.generator.util.IntegerRange;
import org.junit.After;
import org.junit.Before;
@@ -53,7 +53,7 @@ public class TestWhileGenerate {
// ------------------------------------------------------------------------
@Test(expected=NullPointerException.class)
- public void testConstructorProhibitsNullUnaryPredicate() {
+ public void testConstructorProhibitsNullPredicate() {
new WhileGenerate<Integer>(null, whileGenerate);
}
@@ -63,7 +63,7 @@ public class TestWhileGenerate {
}
@Test(expected=NullPointerException.class)
- public void testConstructorProhibitsNullUnaryPredicateOrNullWrappedGenerator() {
+ public void testConstructorProhibitsNullPredicateOrNullWrappedGenerator() {
new WhileGenerate<Integer>(null, null);
}
@@ -75,7 +75,7 @@ public class TestWhileGenerate {
assertTrue(!whileGenerate.equals((WhileGenerate<Integer>)null));
Generator<Integer> aGenerateWithADifferentPredicate = new WhileGenerate<Integer>(
- new UnaryPredicate<Integer>() {
+ new Predicate<Integer>() {
public boolean test(Integer obj) {
return obj < FIVE;
}
@@ -95,7 +95,7 @@ public class TestWhileGenerate {
@Test
public void testGenerate() {
final List<Integer> numbersMinorThanFive = new ArrayList<Integer>();
- whileGenerate.run(new UnaryProcedure<Integer>() {
+ whileGenerate.run(new Procedure<Integer>() {
public void run( Integer obj ) {
numbersMinorThanFive.add(obj);
}
@@ -111,7 +111,7 @@ public class TestWhileGenerate {
private static final Integer FIVE = new Integer(5);
private Generator<Integer> wrappedGenerator = null;
- private UnaryPredicate<Integer> isLessThanFive = new UnaryPredicate<Integer>() {
+ private Predicate<Integer> isLessThanFive = new Predicate<Integer>() {
public boolean test( Integer obj ) {
return obj < FIVE;
}
Modified: commons/proper/functor/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/changes/changes.xml?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/changes/changes.xml (original)
+++ commons/proper/functor/trunk/src/changes/changes.xml Tue Jul 30 22:48:02 2013
@@ -23,6 +23,9 @@
</properties>
<body>
<release version="1.0" date="2012-??-??" description="First release.">
+ <action issue="FUNCTOR-24" dev="kinow">
+ Change default arity of Function, Procedure and Predicate
+ </action>
<action issue="FUNCTOR-27" dev="kinow">
Add static Limit#of method to create new Limit's.
</action>
Modified: commons/proper/functor/trunk/src/site/xdoc/aggregator.xml
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/site/xdoc/aggregator.xml?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/site/xdoc/aggregator.xml (original)
+++ commons/proper/functor/trunk/src/site/xdoc/aggregator.xml Tue Jul 30 22:48:02 2013
@@ -175,8 +175,7 @@ public class AggregatorTesting implement
this.agg = aggregator;
}
- @Override
- public void onTimer(AbstractTimedAggregator<Double> aggregator) {
+ public void onTimer(AbstractTimedAggregator<Double> aggregator, Double evaluation) {
double aggregated = aggregator.evaluate();
/* log the value etc. */
}
@@ -242,8 +241,7 @@ public class AggregatorTesting implement
this.agg = aggregator;
}
- @Override
- public void onTimer(AbstractTimedAggregator<Double> aggregator) {
+ public void onTimer(AbstractTimedAggregator<Double> aggregator, Double evaluation) {
double aggregated = aggregator.evaluate();
/* log the value etc. */
}
@@ -291,7 +289,7 @@ public class AggregatorTesting implement
<p>
For the list-based aggregators, use an instance of
<a href="apidocs/org/apache/commons/functor/aggregator/AbstractListBackedAggregator.html">AbstractListBackedAggregator</a>
- and pass in an instance of <a href="apidocs/org/apache/commons/functor/UnaryFunction.html">UnaryFunction</a>
+ and pass in an instance of <a href="apidocs/org/apache/commons/functor/Function.html">Function</a>
which accepts a <code>List</code> and returns a single object.
</p>
<p>
@@ -308,13 +306,13 @@ public class AggregatorTesting implement
The naming convention is that if the function takes 2
parameters (i.e. it is an instance of <a href="apidocs/org/apache/commons/functor/BinaryFunction.html">BinaryFunction</a> then the
name of the class in this package will contain <code>BinaryFunction</code>, otherwise, if it is an instance
- of <a href="apidocs/org/apache/commons/functor/UnaryFunction.html">UnaryFunction</a> then the
+ of <a href="apidocs/org/apache/commons/functor/Function.html">Function</a> then the
name will only contain <code>Function</code>.
</p>
<p>
The reason behind it is that instances of <code>BinaryFunction</code> can be used with
<a href="apidocs/org/apache/commons/functor/aggregator/AbstractNoStoreAggregator.html">AbstractNoStoreAggregator</a>
- whereas the instances of <code>UnaryFunction</code> can be used
+ whereas the instances of <code>Function</code> can be used
with <a href="apidocs/org/apache/commons/functor/aggregator/AbstractTimedAggregator.html">AbstractTimedAggregator</a>.
</p>
</section>
Modified: commons/proper/functor/trunk/src/site/xdoc/examples.xml
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/site/xdoc/examples.xml?rev=1508677&r1=1508676&r2=1508677&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/site/xdoc/examples.xml (original)
+++ commons/proper/functor/trunk/src/site/xdoc/examples.xml Tue Jul 30 22:48:02 2013
@@ -44,7 +44,7 @@
<source>
List<Integer> numbers = Arrays.asList(1, 2, 3, 4);
-UnaryPredicate<Integer> isEven = new UnaryPredicate<Integer>() {
+Predicate<Integer> isEven = new Predicate<Integer>() {
public boolean test(Integer obj) {
return obj % 2 == 0;
}
@@ -67,7 +67,7 @@ for( Integer number : numbers ) {
<source>
List<Integer> numbers = Arrays.asList(1, 2, 3, 4);
-UnaryFunction<Integer, Integer> doubler = new UnaryFunction<Integer, Integer>() {
+Function<Integer, Integer> doubler = new Function<Integer, Integer>() {
public Integer evaluate(Integer obj) {
return obj * 2;
}
@@ -90,7 +90,7 @@ for( Integer number : numbers ) {
<source>
List<Integer> numbers = Arrays.asList(1, 2, 3, 4);
-UnaryProcedure<Integer> print = new UnaryProcedure<Integer>() {
+Procedure<Integer> print = new Procedure<Integer>() {
public void run(Integer obj) {
System.out.print(obj + " ");
}
@@ -140,19 +140,19 @@ for( Integer number : numbers ) {
<source>
List<Integer> numbers = Arrays.asList(1, 2, 3, 4);
-UnaryPredicate<Integer> isEven = new UnaryPredicate<Integer>() {
+Predicate<Integer> isEven = new Predicate<Integer>() {
public boolean test(Integer obj) {
return obj % 2 == 0;
}
};
-UnaryFunction<Integer, Integer> doubler = new UnaryFunction<Integer, Integer>() {
+Function<Integer, Integer> doubler = new Function<Integer, Integer>() {
public Integer evaluate(Integer obj) {
return obj * 2;
}
};
-UnaryProcedure<Integer> print = new UnaryProcedure<Integer>() {
+Procedure<Integer> print = new Procedure<Integer>() {
public void run(Integer obj) {
System.out.print(obj + " ");
}
@@ -187,13 +187,13 @@ for( Integer number : numbers ) {
integers from 1 to 4 (the right argument is non-inclusive). The
generator is wrapped within a <em>Filtered Generator</em> that applies
the isEven predicate to each integer generated by the former generator.
- Finally, we execute a <em>Composite Unary Procedure</em> that uses
+ Finally, we execute a <em>Composite Procedure</em> that uses
a function to double the value of the integer before printing it.
</p>
<source>
Generator<Integer> integerGenerator = new IntegerRange(1, 5); // inclusive, exclusive
-UnaryPredicate<Integer> isEven = new UnaryPredicate<Integer>() {
+Predicate<Integer> isEven = new Predicate<Integer>() {
public boolean test(Integer obj) {
return obj % 2 == 0;
}
@@ -202,20 +202,20 @@ UnaryPredicate<Integer> isEven = n
FilteredGenerator<Integer> filteredGenerator =
new FilteredGenerator<Integer>(integerGenerator, isEven);
-UnaryFunction<Integer, Integer> doubler = new UnaryFunction<Integer, Integer>() {
+Function<Integer, Integer> doubler = new Function<Integer, Integer>() {
public Integer evaluate(Integer obj) {
return obj * 2;
}
};
-UnaryProcedure<Integer> print = new UnaryProcedure<Integer>() {
+Procedure<Integer> print = new Procedure<Integer>() {
public void run(Integer obj) {
System.out.print(obj + " ");
}
};
-CompositeUnaryProcedure<Integer> compositeProcedure =
- new CompositeUnaryProcedure<Integer>(print);
+CompositeProcedure<Integer> compositeProcedure =
+ new CompositeProcedure<Integer>(print);
filteredGenerator.run(compositeProcedure.of(doubler));
</source>