You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mb...@apache.org on 2008/06/09 19:17:43 UTC
svn commit: r665786 [1/6] - in /commons/sandbox/functor/trunk/src:
main/java/org/apache/commons/functor/adapter/
main/java/org/apache/commons/functor/core/
main/java/org/apache/commons/functor/core/algorithm/
main/java/org/apache/commons/functor/core/c...
Author: mbenson
Date: Mon Jun 9 10:17:39 2008
New Revision: 665786
URL: http://svn.apache.org/viewvc?rev=665786&view=rev
Log:
generification
Added:
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/one/ArithmeticOperation.java (with props)
Modified:
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryFunctionBinaryPredicate.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryFunctionBinaryProcedure.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryPredicateBinaryFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryProcedureBinaryFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BoundFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BoundPredicate.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BoundProcedure.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionPredicate.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionProcedure.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionUnaryFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreLeftFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreLeftPredicate.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreLeftProcedure.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightPredicate.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightProcedure.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundPredicate.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundProcedure.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/PredicateFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/PredicateUnaryPredicate.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/ProcedureFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/ProcedureUnaryProcedure.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundPredicate.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundProcedure.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/UnaryFunctionUnaryPredicate.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/UnaryFunctionUnaryProcedure.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/UnaryPredicateUnaryFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/UnaryProcedureUnaryFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/Constant.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/Identity.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/IsEqual.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/IsNotEqual.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/IsNotNull.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/IsNull.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/LeftIdentity.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/Limit.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/NoOp.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/Offset.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/RightIdentity.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/FindWithinGenerator.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/FoldLeft.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/FoldRight.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/GeneratorContains.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/InPlaceTransform.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/IndexOfInGenerator.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/PredicatedLoop.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/RecursiveEvaluation.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/RemoveMatching.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/algorithm/RetainMatching.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterator.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/IsElementOf.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/IsEmpty.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/Size.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/TransformedIterator.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/ComparatorFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsEquivalent.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsGreaterThan.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsGreaterThanOrEqual.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsLessThan.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsLessThanOrEqual.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsNotEquivalent.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsWithinRange.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/Max.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/Min.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BaseBinaryPredicateList.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BasePredicateList.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BaseUnaryPredicateList.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryAnd.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryCompositeBinaryFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryNot.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinaryOr.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/BinarySequence.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Composite.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/CompositeUnaryFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/CompositeUnaryPredicate.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/CompositeUnaryProcedure.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Conditional.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalBinaryFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalBinaryPredicate.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalBinaryProcedure.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalUnaryFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalUnaryPredicate.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/ConditionalUnaryProcedure.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Or.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/Sequence.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/TransposedFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/TransposedPredicate.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/TransposedProcedure.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryAnd.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryFunction.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryCompositeBinaryPredicate.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryNot.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnaryOr.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/composite/UnarySequence.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/BaseGenerator.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/FilteredGenerator.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/GenerateUntil.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/GenerateWhile.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/Generator.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/IteratorToGeneratorAdapter.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/TransformedGenerator.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/UntilGenerate.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/WhileGenerate.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/CollectionTransformer.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/EachElement.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/IntegerRange.java
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/generator/util/LongRange.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/TestAlgorithms.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryFunctionBinaryProcedure.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryPredicateBinaryFunction.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestBinaryProcedureBinaryFunction.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestIgnoreLeftFunction.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestIgnoreRightFunction.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundFunction.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundPredicate.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestLeftBoundProcedure.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundFunction.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundPredicate.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestRightBoundProcedure.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestAll.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestConstant.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIdentity.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsEqual.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsNotEqual.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsNotNull.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestIsNull.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestLeftIdentity.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestRightIdentity.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterator.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestIsElementOf.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestIsEmpty.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestSize.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestTransformedIterator.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestComparatorFunction.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsEquivalent.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsGreaterThan.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsGreaterThanOrEqual.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsLessThan.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsLessThanOrEqual.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsNotEquivalent.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMax.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMin.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryAnd.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryCompositeBinaryFunction.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinarySequence.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestComposite.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestCompositeUnaryFunction.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestCompositeUnaryPredicate.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestCompositeUnaryProcedure.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestConditionalBinaryFunction.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestConditionalBinaryProcedure.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestSequence.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedFunction.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedPredicate.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryCompositeBinaryFunction.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryCompositeBinaryPredicate.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnarySequence.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/FlexiMapExample.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/QuicksortExample.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/Abs.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/DataMunger.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/IsInteger.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/NthColumn.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/four/ToInteger.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/one/Add.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/one/Divide.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/one/Mod.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/one/Multiply.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/one/Product.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/one/Subtract.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/one/SupermarketPricingExample.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/kata/one/ToMoney.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/Contains.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/Lines.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/StartsWith.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/Sum.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/TestLines.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/lines/WordCount.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/example/map/TestPredicatedMap.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/TestBaseGenerator.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/TestIteratorToGeneratorAdapter.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/util/TestEachElement.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/util/TestIntegerRange.java
commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/generator/util/TestLongRange.java
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryFunctionBinaryPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryFunctionBinaryPredicate.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryFunctionBinaryPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryFunctionBinaryPredicate.java Mon Jun 9 10:17:39 2008
@@ -37,16 +37,16 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class BinaryFunctionBinaryPredicate implements BinaryPredicate, Serializable {
+public final class BinaryFunctionBinaryPredicate<L, R> implements BinaryPredicate<L, R>, Serializable {
/** The {@link BinaryFunction BinaryFunction} I'm wrapping. */
- private BinaryFunction function = null;
+ private BinaryFunction<? super L, ? super R, Boolean> function;
/**
* Create an {@link BinaryPredicate BinaryPredicate} wrapping
* the given {@link BinaryFunction BinaryFunction}.
* @param function the {@link BinaryFunction BinaryFunction} to wrap
*/
- public BinaryFunctionBinaryPredicate(BinaryFunction function) {
+ public BinaryFunctionBinaryPredicate(BinaryFunction<? super L, ? super R, Boolean> function) {
this.function = function;
}
@@ -59,8 +59,8 @@
* @throws NullPointerException if my underlying function returns <code>null</code>
* @throws ClassCastException if my underlying function returns a non-<code>Boolean</code>
*/
- public boolean test(Object left, Object right) {
- return ((Boolean) (function.evaluate(left, right))).booleanValue();
+ public boolean test(L left, R right) {
+ return function.evaluate(left, right);
}
/**
@@ -68,7 +68,7 @@
*/
public boolean equals(Object that) {
return that == this
- || (that instanceof BinaryFunctionBinaryPredicate && equals((BinaryFunctionBinaryPredicate) that));
+ || (that instanceof BinaryFunctionBinaryPredicate && equals((BinaryFunctionBinaryPredicate<?, ?>) that));
}
/**
@@ -76,7 +76,7 @@
* @param that BinaryFunctionBinaryPredicate to test
* @return boolean
*/
- public boolean equals(BinaryFunctionBinaryPredicate that) {
+ public boolean equals(BinaryFunctionBinaryPredicate<?, ?> that) {
return null != that && (null == function ? null == that.function : function.equals(that.function));
}
@@ -111,8 +111,9 @@
* {@link BinaryFunction BinaryFunction}, or <code>null</code>
* if the given <code>BinaryFunction</code> is <code>null</code>
*/
- public static BinaryFunctionBinaryPredicate adapt(BinaryFunction function) {
- return null == function ? null : new BinaryFunctionBinaryPredicate(function);
+ public static <L, R, T> BinaryFunctionBinaryPredicate<L, R> adapt(
+ BinaryFunction<? super L, ? super R, Boolean> function) {
+ return null == function ? null : new BinaryFunctionBinaryPredicate<L, R>(function);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryFunctionBinaryProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryFunctionBinaryProcedure.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryFunctionBinaryProcedure.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryFunctionBinaryProcedure.java Mon Jun 9 10:17:39 2008
@@ -37,17 +37,17 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class BinaryFunctionBinaryProcedure implements BinaryProcedure, Serializable {
+public final class BinaryFunctionBinaryProcedure<L, R> implements BinaryProcedure<L, R>, Serializable {
/** The {@link BinaryFunction BinaryFunction} I'm wrapping. */
- private BinaryFunction function = null;
+ private BinaryFunction<? super L, ? super R, ?> function;
/**
* Create an {@link BinaryProcedure BinaryProcedure} wrapping
* the given {@link BinaryFunction BinaryFunction}.
* @param function the {@link BinaryFunction BinaryFunction} to wrap
*/
- public BinaryFunctionBinaryProcedure(BinaryFunction function) {
+ public BinaryFunctionBinaryProcedure(BinaryFunction<? super L, ? super R, ?> function) {
this.function = function;
}
@@ -56,7 +56,7 @@
* ignore its returned value.
* {@inheritDoc}
*/
- public void run(Object left, Object right) {
+ public void run(L left, R right) {
function.evaluate(left, right);
}
@@ -65,7 +65,7 @@
*/
public boolean equals(Object that) {
return that == this
- || (that instanceof BinaryFunctionBinaryProcedure && equals((BinaryFunctionBinaryProcedure) that));
+ || (that instanceof BinaryFunctionBinaryProcedure && equals((BinaryFunctionBinaryProcedure<?, ?>) that));
}
/**
@@ -73,7 +73,7 @@
* @param that BinaryFunctionBinaryPredicate to compare
* @return boolean
*/
- public boolean equals(BinaryFunctionBinaryProcedure that) {
+ public boolean equals(BinaryFunctionBinaryProcedure<?, ?> that) {
return null != that && (null == function ? null == that.function : function.equals(that.function));
}
@@ -108,8 +108,8 @@
* {@link BinaryFunction BinaryFunction}, or <code>null</code>
* if the given <code>BinaryFunction</code> is <code>null</code>
*/
- public static BinaryFunctionBinaryProcedure adapt(BinaryFunction function) {
- return null == function ? null : new BinaryFunctionBinaryProcedure(function);
+ public static <L, R> BinaryFunctionBinaryProcedure<L, R> adapt(BinaryFunction<? super L, ? super R, ?> function) {
+ return null == function ? null : new BinaryFunctionBinaryProcedure<L, R>(function);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryPredicateBinaryFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryPredicateBinaryFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryPredicateBinaryFunction.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryPredicateBinaryFunction.java Mon Jun 9 10:17:39 2008
@@ -37,15 +37,15 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class BinaryPredicateBinaryFunction implements BinaryFunction, Serializable {
+public final class BinaryPredicateBinaryFunction<L, R> implements BinaryFunction<L, R, Boolean>, Serializable {
/** The {@link BinaryPredicate BinaryPredicate} I'm wrapping. */
- private BinaryPredicate predicate = null;
+ private BinaryPredicate<? super L, ? super R> predicate;
/**
* Create a new BinaryPredicateBinaryFunction.
* @param predicate to adapt
*/
- public BinaryPredicateBinaryFunction(BinaryPredicate predicate) {
+ public BinaryPredicateBinaryFunction(BinaryPredicate<? super L, ? super R> predicate) {
this.predicate = predicate;
}
@@ -57,7 +57,7 @@
*
* @return a non-<code>null</code> <code>Boolean</code> instance
*/
- public Object evaluate(Object left, Object right) {
+ public Boolean evaluate(L left, R right) {
return predicate.test(left, right) ? Boolean.TRUE : Boolean.FALSE;
}
@@ -66,7 +66,7 @@
*/
public boolean equals(Object that) {
return that == this
- || (that instanceof BinaryPredicateBinaryFunction && equals((BinaryPredicateBinaryFunction) that));
+ || (that instanceof BinaryPredicateBinaryFunction && equals((BinaryPredicateBinaryFunction<?, ?>) that));
}
/**
@@ -74,7 +74,7 @@
* @param that BinaryPredicateBinaryFunction to test
* @return boolean
*/
- public boolean equals(BinaryPredicateBinaryFunction that) {
+ public boolean equals(BinaryPredicateBinaryFunction<?, ?> that) {
return null != that && (null == predicate ? null == that.predicate : predicate.equals(that.predicate));
}
@@ -109,8 +109,8 @@
* {@link BinaryPredicate BinaryPredicate}, or <code>null</code>
* if the given <code>BinaryPredicate</code> is <code>null</code>
*/
- public static BinaryPredicateBinaryFunction adapt(BinaryPredicate predicate) {
- return null == predicate ? null : new BinaryPredicateBinaryFunction(predicate);
+ public static <L, R> BinaryPredicateBinaryFunction<L, R> adapt(BinaryPredicate<? super L, ? super R> predicate) {
+ return null == predicate ? null : new BinaryPredicateBinaryFunction<L, R>(predicate);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryProcedureBinaryFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryProcedureBinaryFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryProcedureBinaryFunction.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BinaryProcedureBinaryFunction.java Mon Jun 9 10:17:39 2008
@@ -38,22 +38,25 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class BinaryProcedureBinaryFunction implements BinaryFunction, Serializable {
+public final class BinaryProcedureBinaryFunction<L, R, T> implements BinaryFunction<L, R, T>, Serializable {
/** The {@link BinaryProcedure BinaryProcedure} I'm wrapping. */
- private BinaryProcedure procedure = null;
+ private BinaryProcedure<? super L, ? super R> procedure;
/**
* Create a new BinaryProcedureBinaryFunction.
* @param procedure to adapt as a BinaryFunction
*/
- public BinaryProcedureBinaryFunction(BinaryProcedure procedure) {
+ public BinaryProcedureBinaryFunction(BinaryProcedure<? super L, ? super R> procedure) {
+ if (procedure == null) {
+ throw new IllegalArgumentException("BinaryProcedure argument was null");
+ }
this.procedure = procedure;
}
/**
* {@inheritDoc}
*/
- public Object evaluate(Object left, Object right) {
+ public T evaluate(L left, R right) {
procedure.run(left, right);
return null;
}
@@ -63,7 +66,7 @@
*/
public boolean equals(Object that) {
return that == this
- || (that instanceof BinaryProcedureBinaryFunction && equals((BinaryProcedureBinaryFunction) that));
+ || (that instanceof BinaryProcedureBinaryFunction && equals((BinaryProcedureBinaryFunction<?, ?, ?>) that));
}
/**
@@ -71,7 +74,7 @@
* @param that the BinaryProcedureBinaryFunction to test
* @return boolean
*/
- public boolean equals(BinaryProcedureBinaryFunction that) {
+ public boolean equals(BinaryProcedureBinaryFunction<?, ?, ?> that) {
return null != that && (null == procedure ? null == that.procedure : procedure.equals(that.procedure));
}
@@ -106,8 +109,8 @@
* {@link BinaryFunction BinaryFunction}, or <code>null</code>
* if the given <code>BinaryFunction</code> is <code>null</code>
*/
- public static BinaryProcedureBinaryFunction adapt(BinaryProcedure procedure) {
- return null == procedure ? null : new BinaryProcedureBinaryFunction(procedure);
+ public static <L, R, T> BinaryProcedureBinaryFunction<L, R, T> adapt(BinaryProcedure<? super L, ? super R> procedure) {
+ return null == procedure ? null : new BinaryProcedureBinaryFunction<L, R, T>(procedure);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BoundFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BoundFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BoundFunction.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BoundFunction.java Mon Jun 9 10:17:39 2008
@@ -38,18 +38,18 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class BoundFunction implements Function, Serializable {
+public final class BoundFunction<A, T> implements Function<T>, Serializable {
/** The {@link UnaryFunction UnaryFunction} I'm wrapping. */
- private UnaryFunction function = null;
+ private UnaryFunction<? super A, ? extends T> function;
/** The parameter to pass to that function. */
- private Object param = null;
+ private A param = null;
/**
* Create a new BoundFunction.
* @param function the function to adapt
* @param arg the constant argument to use
*/
- public BoundFunction(UnaryFunction function, Object arg) {
+ public BoundFunction(UnaryFunction<? super A, ? extends T> function, A arg) {
this.function = function;
this.param = arg;
}
@@ -57,7 +57,7 @@
/**
* {@inheritDoc}
*/
- public Object evaluate() {
+ public T evaluate() {
return function.evaluate(param);
}
@@ -65,7 +65,7 @@
* {@inheritDoc}
*/
public boolean equals(Object that) {
- return that == this || (that instanceof BoundFunction && equals((BoundFunction) that));
+ return that == this || (that instanceof BoundFunction && equals((BoundFunction<?, ?>) that));
}
/**
@@ -73,7 +73,7 @@
* @param that BoundFunction to test
* @return boolean
*/
- public boolean equals(BoundFunction that) {
+ public boolean equals(BoundFunction<?, ?> that) {
return null != that
&& (null == function ? null == that.function : function.equals(that.function))
&& (null == param ? null == that.param : param.equals(that.param));
@@ -119,8 +119,8 @@
* {@link UnaryFunction UnaryFunction}, or <code>null</code>
* if the given <code>UnaryFunction</code> is <code>null</code>
*/
- public static BoundFunction bind(UnaryFunction function, Object arg) {
- return null == function ? null : new BoundFunction(function, arg);
+ public static <A, T> BoundFunction<A, T> bind(UnaryFunction<? super A, ? extends T> function, A arg) {
+ return null == function ? null : new BoundFunction<A, T>(function, arg);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BoundPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BoundPredicate.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BoundPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BoundPredicate.java Mon Jun 9 10:17:39 2008
@@ -38,18 +38,18 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class BoundPredicate implements Predicate, Serializable {
+public final class BoundPredicate<A> implements Predicate, Serializable {
/** The {@link UnaryPredicate UnaryPredicate} I'm wrapping. */
- private UnaryPredicate predicate = null;
+ private UnaryPredicate<? super A> predicate;
/** The parameter to pass to that predicate. */
- private Object param = null;
+ private A param;
/**
* Create a new BoundPredicate.
* @param predicate the predicate to adapt
* @param arg the constant argument to use
*/
- public BoundPredicate(UnaryPredicate predicate, Object arg) {
+ public BoundPredicate(UnaryPredicate<? super A> predicate, A arg) {
this.predicate = predicate;
this.param = arg;
}
@@ -65,7 +65,7 @@
* {@inheritDoc}
*/
public boolean equals(Object that) {
- return that == this || (that instanceof BoundPredicate && equals((BoundPredicate) that));
+ return that == this || (that instanceof BoundPredicate && equals((BoundPredicate<?>) that));
}
/**
@@ -73,7 +73,7 @@
* @param that BoundPredicate to test
* @return boolean
*/
- public boolean equals(BoundPredicate that) {
+ public boolean equals(BoundPredicate<?> that) {
return null != that
&& (null == predicate ? null == that.predicate : predicate.equals(that.predicate))
&& (null == param ? null == that.param : param.equals(that.param));
@@ -119,8 +119,8 @@
* {@link UnaryPredicate UnaryPredicate}, or <code>null</code>
* if the given <code>UnaryPredicate</code> is <code>null</code>
*/
- public static BoundPredicate bind(UnaryPredicate predicate, Object arg) {
- return null == predicate ? null : new BoundPredicate(predicate, arg);
+ public static <A> BoundPredicate<A> bind(UnaryPredicate<? super A> predicate, A arg) {
+ return null == predicate ? null : new BoundPredicate<A>(predicate, arg);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BoundProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BoundProcedure.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BoundProcedure.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/BoundProcedure.java Mon Jun 9 10:17:39 2008
@@ -38,18 +38,18 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class BoundProcedure implements Procedure, Serializable {
+public final class BoundProcedure<A> implements Procedure, Serializable {
/** The {@link UnaryProcedure UnaryProcedure} I'm wrapping. */
- private UnaryProcedure procedure = null;
+ private UnaryProcedure<? super A> procedure;
/** The parameter to pass to that procedure. */
- private Object param = null;
+ private A param;
/**
* Create a new BoundProcedure.
* @param procedure the procedure to adapt
* @param arg the constant argument to use
*/
- public BoundProcedure(UnaryProcedure procedure, Object arg) {
+ public BoundProcedure(UnaryProcedure<? super A> procedure, A arg) {
this.procedure = procedure;
this.param = arg;
}
@@ -65,7 +65,7 @@
* {@inheritDoc}
*/
public boolean equals(Object that) {
- return that == this || (that instanceof BoundProcedure && equals((BoundProcedure) that));
+ return that == this || (that instanceof BoundProcedure && equals((BoundProcedure<?>) that));
}
/**
@@ -73,7 +73,7 @@
* @param that the BoundProcedure to test
* @return boolean
*/
- public boolean equals(BoundProcedure that) {
+ public boolean equals(BoundProcedure<?> that) {
return null != that
&& (null == procedure ? null == that.procedure : procedure.equals(that.procedure))
&& (null == param ? null == that.param : param.equals(that.param));
@@ -118,8 +118,8 @@
* {@link UnaryProcedure UnaryProcedure}, or <code>null</code>
* if the given <code>UnaryProcedure</code> is <code>null</code>
*/
- public static BoundProcedure bind(UnaryProcedure procedure, Object arg) {
- return null == procedure ? null : new BoundProcedure(procedure, arg);
+ public static <A> BoundProcedure<A> bind(UnaryProcedure<? super A> procedure, A arg) {
+ return null == procedure ? null : new BoundProcedure<A>(procedure, arg);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionPredicate.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionPredicate.java Mon Jun 9 10:17:39 2008
@@ -39,13 +39,13 @@
public final class FunctionPredicate implements Predicate, Serializable {
/** The {@link Function Function} I'm wrapping. */
- private Function function = null;
+ private Function<Boolean> function;
/**
* Create a new FunctionPredicate.
* @param function to adapt
*/
- public FunctionPredicate(Function function) {
+ public FunctionPredicate(Function<Boolean> function) {
this.function = function;
}
@@ -58,7 +58,7 @@
* @throws ClassCastException if my underlying function returns a non-<code>Boolean</code>
*/
public boolean test() {
- return ((Boolean) (function.evaluate())).booleanValue();
+ return function.evaluate();
}
/**
@@ -100,7 +100,7 @@
* @param function to adapt
* @return FunctionPredicate
*/
- public static FunctionPredicate adapt(Function function) {
+ public static FunctionPredicate adapt(Function<Boolean> function) {
return null == function ? null : new FunctionPredicate(function);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionProcedure.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionProcedure.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionProcedure.java Mon Jun 9 10:17:39 2008
@@ -39,14 +39,14 @@
*/
public final class FunctionProcedure implements Procedure, Serializable {
/** The {@link Function Function} I'm wrapping. */
- private Function function = null;
+ private Function<?> function;
/**
* Create an {@link Procedure Procedure} wrapping
* the given {@link Function Function}.
* @param function the {@link Function Function} to wrap
*/
- public FunctionProcedure(Function function) {
+ public FunctionProcedure(Function<?> function) {
this.function = function;
}
@@ -106,7 +106,7 @@
* {@link Function Function}, or <code>null</code>
* if the given <code>Function</code> is <code>null</code>
*/
- public static FunctionProcedure adapt(Function function) {
+ public static FunctionProcedure adapt(Function<?> function) {
return null == function ? null : new FunctionProcedure(function);
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionUnaryFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionUnaryFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionUnaryFunction.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionUnaryFunction.java Mon Jun 9 10:17:39 2008
@@ -38,22 +38,22 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class FunctionUnaryFunction implements UnaryFunction, Serializable {
+public final class FunctionUnaryFunction<A, T> implements UnaryFunction<A, T>, Serializable {
/** The {@link Function Function} I'm wrapping. */
- private Function function = null;
+ private Function<? extends T> function;
/**
* Create a new FunctionUnaryFunction.
* @param function to adapt
*/
- public FunctionUnaryFunction(Function function) {
+ public FunctionUnaryFunction(Function<? extends T> function) {
this.function = function;
}
/**
* {@inheritDoc}
*/
- public Object evaluate(Object obj) {
+ public T evaluate(A obj) {
return function.evaluate();
}
@@ -61,7 +61,7 @@
* {@inheritDoc}
*/
public boolean equals(Object that) {
- return that == this || (that instanceof FunctionUnaryFunction && equals((FunctionUnaryFunction) that));
+ return that == this || (that instanceof FunctionUnaryFunction && equals((FunctionUnaryFunction<?, ?>) that));
}
/**
@@ -69,7 +69,7 @@
* @param that FunctionUnaryFunction to test
* @return boolean
*/
- public boolean equals(FunctionUnaryFunction that) {
+ public boolean equals(FunctionUnaryFunction<?, ?> that) {
return null != that && (null == function ? null == that.function : function.equals(that.function));
}
@@ -96,8 +96,8 @@
* @param function to adapt
* @return FunctionUnaryFunction
*/
- public static FunctionUnaryFunction adapt(Function function) {
- return null == function ? null : new FunctionUnaryFunction(function);
+ public static <A, T> FunctionUnaryFunction<A, T> adapt(Function<? extends T> function) {
+ return null == function ? null : new FunctionUnaryFunction<A, T>(function);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreLeftFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreLeftFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreLeftFunction.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreLeftFunction.java Mon Jun 9 10:17:39 2008
@@ -38,22 +38,25 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class IgnoreLeftFunction implements BinaryFunction, Serializable {
+public final class IgnoreLeftFunction<L, R, T> implements BinaryFunction<L, R, T>, Serializable {
/** The {@link UnaryFunction UnaryFunction} I'm wrapping. */
- private UnaryFunction function = null;
+ private UnaryFunction<? super R, ? extends T> function = null;
/**
* Create a new IgnoreLeftFunction.
* @param function UnaryFunction for right argument
*/
- public IgnoreLeftFunction(UnaryFunction function) {
+ public IgnoreLeftFunction(UnaryFunction<? super R, ? extends T> function) {
+ if (function == null) {
+ throw new IllegalArgumentException("UnaryFunction argument was null");
+ }
this.function = function;
}
/**
* {@inheritDoc}
*/
- public Object evaluate(Object left, Object right) {
+ public T evaluate(L left, R right) {
return function.evaluate(right);
}
@@ -61,7 +64,7 @@
* {@inheritDoc}
*/
public boolean equals(Object that) {
- return that == this || (that instanceof IgnoreLeftFunction && equals((IgnoreLeftFunction) that));
+ return that == this || (that instanceof IgnoreLeftFunction && equals((IgnoreLeftFunction<?, ?, ?>) that));
}
/**
@@ -69,7 +72,7 @@
* @param that IgnoreLeftFunction to test
* @return boolean
*/
- public boolean equals(IgnoreLeftFunction that) {
+ public boolean equals(IgnoreLeftFunction<?, ?, ?> that) {
return null != that && (null == function ? null == that.function : function.equals(that.function));
}
@@ -96,8 +99,8 @@
* @param function to adapt
* @return IgnoreLeftFunction
*/
- public static IgnoreLeftFunction adapt(UnaryFunction function) {
- return null == function ? null : new IgnoreLeftFunction(function);
+ public static <L, R, T> IgnoreLeftFunction<L, R, T> adapt(UnaryFunction<? super R, ? extends T> function) {
+ return null == function ? null : new IgnoreLeftFunction<L, R, T>(function);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreLeftPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreLeftPredicate.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreLeftPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreLeftPredicate.java Mon Jun 9 10:17:39 2008
@@ -38,22 +38,22 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class IgnoreLeftPredicate implements BinaryPredicate, Serializable {
+public final class IgnoreLeftPredicate<A> implements BinaryPredicate<Object, A>, Serializable {
/** The {@link UnaryPredicate UnaryPredicate} I'm wrapping. */
- private UnaryPredicate predicate = null;
+ private UnaryPredicate<? super A> predicate;
/**
* Create a new IgnoreLeftPredicate.
* @param predicate the right predicate
*/
- public IgnoreLeftPredicate(UnaryPredicate predicate) {
+ public IgnoreLeftPredicate(UnaryPredicate<? super A> predicate) {
this.predicate = predicate;
}
/**
* {@inheritDoc}
*/
- public boolean test(Object left, Object right) {
+ public boolean test(Object left, A right) {
return predicate.test(right);
}
@@ -61,7 +61,7 @@
* {@inheritDoc}
*/
public boolean equals(Object that) {
- return that == this || (that instanceof IgnoreLeftPredicate && equals((IgnoreLeftPredicate) that));
+ return that == this || (that instanceof IgnoreLeftPredicate && equals((IgnoreLeftPredicate<?>) that));
}
/**
@@ -69,7 +69,7 @@
* @param that the IgnoreLeftPredicate to test
* @return boolean
*/
- public boolean equals(IgnoreLeftPredicate that) {
+ public boolean equals(IgnoreLeftPredicate<?> that) {
return null != that && (null == predicate ? null == that.predicate : predicate.equals(that.predicate));
}
@@ -96,8 +96,8 @@
* @param predicate to adapt
* @return IgnoreLeftPredicate
*/
- public static IgnoreLeftPredicate adapt(UnaryPredicate predicate) {
- return null == predicate ? null : new IgnoreLeftPredicate(predicate);
+ public static <A> IgnoreLeftPredicate<A> adapt(UnaryPredicate<? super A> predicate) {
+ return null == predicate ? null : new IgnoreLeftPredicate<A>(predicate);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreLeftProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreLeftProcedure.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreLeftProcedure.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreLeftProcedure.java Mon Jun 9 10:17:39 2008
@@ -38,30 +38,30 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class IgnoreLeftProcedure implements BinaryProcedure, Serializable {
+public final class IgnoreLeftProcedure<A> implements BinaryProcedure<Object, A>, Serializable {
/** The {@link UnaryProcedure UnaryProcedure} I'm wrapping. */
- private UnaryProcedure procedure = null;
+ private UnaryProcedure<? super A> procedure;
/**
* Create a new IgnoreLeftProcedure.
* @param procedure to adapt
*/
- public IgnoreLeftProcedure(UnaryProcedure procedure) {
+ public IgnoreLeftProcedure(UnaryProcedure<? super A> procedure) {
this.procedure = procedure;
}
/**
* {@inheritDoc}
*/
- public void run(Object left, Object right) {
- procedure.run(left);
+ public void run(Object left, A right) {
+ procedure.run(right);
}
/**
* {@inheritDoc}
*/
public boolean equals(Object that) {
- return that == this || (that instanceof IgnoreLeftProcedure && equals((IgnoreLeftProcedure) that));
+ return that == this || (that instanceof IgnoreLeftProcedure && equals((IgnoreLeftProcedure<?>) that));
}
/**
@@ -69,7 +69,7 @@
* @param that IgnoreLeftProcedure to test
* @return boolean
*/
- public boolean equals(IgnoreLeftProcedure that) {
+ public boolean equals(IgnoreLeftProcedure<?> that) {
return null != that && (null == procedure ? null == that.procedure : procedure.equals(that.procedure));
}
@@ -96,8 +96,8 @@
* @param procedure to adapt
* @return IgnoreLeftProcedure
*/
- public static IgnoreLeftProcedure adapt(UnaryProcedure procedure) {
- return null == procedure ? null : new IgnoreLeftProcedure(procedure);
+ public static <A> IgnoreLeftProcedure<A> adapt(UnaryProcedure<? super A> procedure) {
+ return null == procedure ? null : new IgnoreLeftProcedure<A>(procedure);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightFunction.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightFunction.java Mon Jun 9 10:17:39 2008
@@ -38,22 +38,22 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class IgnoreRightFunction implements BinaryFunction, Serializable {
+public final class IgnoreRightFunction<L, R, T> implements BinaryFunction<L, R, T>, Serializable {
/** The {@link UnaryFunction UnaryFunction} I'm wrapping. */
- private UnaryFunction function = null;
+ private UnaryFunction<? super L, ? extends T> function;
/**
* Create a new IgnoreRightFunction.
* @param function UnaryFunction to wrap
*/
- public IgnoreRightFunction(UnaryFunction function) {
+ public IgnoreRightFunction(UnaryFunction<? super L, ? extends T> function) {
this.function = function;
}
/**
* {@inheritDoc}
*/
- public Object evaluate(Object left, Object right) {
+ public T evaluate(L left, R right) {
return function.evaluate(left);
}
@@ -61,7 +61,7 @@
* {@inheritDoc}
*/
public boolean equals(Object that) {
- return that == this || (that instanceof IgnoreRightFunction && equals((IgnoreRightFunction) that));
+ return that == this || (that instanceof IgnoreRightFunction && equals((IgnoreRightFunction<?, ?, ?>) that));
}
/**
@@ -69,7 +69,7 @@
* @param that IgnoreRightFunction to test
* @return boolean
*/
- public boolean equals(IgnoreRightFunction that) {
+ public boolean equals(IgnoreRightFunction<?, ?, ?> that) {
return null != that && (null == function ? null == that.function : function.equals(that.function));
}
@@ -96,8 +96,8 @@
* @param function UnaryFunction to adapt
* @return IgnoreRightFunction
*/
- public static IgnoreRightFunction adapt(UnaryFunction function) {
- return null == function ? null : new IgnoreRightFunction(function);
+ public static <L, R, T> IgnoreRightFunction<L, R, T> adapt(UnaryFunction<? super L, ? extends T> function) {
+ return null == function ? null : new IgnoreRightFunction<L, R, T>(function);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightPredicate.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightPredicate.java Mon Jun 9 10:17:39 2008
@@ -38,22 +38,22 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class IgnoreRightPredicate implements BinaryPredicate, Serializable {
+public final class IgnoreRightPredicate<A> implements BinaryPredicate<A, Object>, Serializable {
/** The {@link UnaryPredicate UnaryPredicate} I'm wrapping. */
- private UnaryPredicate predicate = null;
+ private UnaryPredicate<? super A> predicate;
/**
* Create a new IgnoreRightPredicate.
* @param predicate left
*/
- public IgnoreRightPredicate(UnaryPredicate predicate) {
+ public IgnoreRightPredicate(UnaryPredicate<? super A> predicate) {
this.predicate = predicate;
}
/**
* {@inheritDoc}
*/
- public boolean test(Object left, Object right) {
+ public boolean test(A left, Object right) {
return predicate.test(left);
}
@@ -61,7 +61,7 @@
* {@inheritDoc}
*/
public boolean equals(Object that) {
- return that == this || (that instanceof IgnoreRightPredicate && equals((IgnoreRightPredicate) that));
+ return that == this || (that instanceof IgnoreRightPredicate && equals((IgnoreRightPredicate<?>) that));
}
/**
@@ -69,7 +69,7 @@
* @param that IgnoreRightPredicate to test
* @return boolean
*/
- public boolean equals(IgnoreRightPredicate that) {
+ public boolean equals(IgnoreRightPredicate<?> that) {
return null != that && (null == predicate ? null == that.predicate : predicate.equals(that.predicate));
}
@@ -96,8 +96,8 @@
* @param predicate to adapt
* @return IgnoreRightPredicate
*/
- public static IgnoreRightPredicate adapt(UnaryPredicate predicate) {
- return null == predicate ? null : new IgnoreRightPredicate(predicate);
+ public static <A> IgnoreRightPredicate<A> adapt(UnaryPredicate<? super A> predicate) {
+ return null == predicate ? null : new IgnoreRightPredicate<A>(predicate);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightProcedure.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightProcedure.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/IgnoreRightProcedure.java Mon Jun 9 10:17:39 2008
@@ -38,22 +38,22 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class IgnoreRightProcedure implements BinaryProcedure, Serializable {
+public final class IgnoreRightProcedure<A> implements BinaryProcedure<A, Object>, Serializable {
/** The {@link UnaryProcedure UnaryProcedure} I'm wrapping. */
- private UnaryProcedure procedure = null;
+ private UnaryProcedure<? super A> procedure;
/**
* Create a new IgnoreRightProcedure.
* @param procedure UnaryProcedure to adapt
*/
- public IgnoreRightProcedure(UnaryProcedure procedure) {
+ public IgnoreRightProcedure(UnaryProcedure<? super A> procedure) {
this.procedure = procedure;
}
/**
* {@inheritDoc}
*/
- public void run(Object left, Object right) {
+ public void run(A left, Object right) {
procedure.run(left);
}
@@ -61,7 +61,7 @@
* {@inheritDoc}
*/
public boolean equals(Object that) {
- return that == this || (that instanceof IgnoreRightProcedure && equals((IgnoreRightProcedure) that));
+ return that == this || (that instanceof IgnoreRightProcedure && equals((IgnoreRightProcedure<?>) that));
}
/**
@@ -69,7 +69,7 @@
* @param that IgnoreRightProcedure to test
* @return boolean
*/
- public boolean equals(IgnoreRightProcedure that) {
+ public boolean equals(IgnoreRightProcedure<?> that) {
return null != that && (null == procedure ? null == that.procedure : procedure.equals(that.procedure));
}
@@ -96,8 +96,8 @@
* @param procedure UnaryProcedure to adapt
* @return IgnoreRightProcedure
*/
- public static IgnoreRightProcedure adapt(UnaryProcedure procedure) {
- return null == procedure ? null : new IgnoreRightProcedure(procedure);
+ public static <A> IgnoreRightProcedure<A> adapt(UnaryProcedure<? super A> procedure) {
+ return null == procedure ? null : new IgnoreRightProcedure<A>(procedure);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundFunction.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundFunction.java Mon Jun 9 10:17:39 2008
@@ -38,18 +38,21 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class LeftBoundFunction implements UnaryFunction, Serializable {
+public final class LeftBoundFunction<L, R, T> implements UnaryFunction<R, T>, Serializable {
/** The {@link BinaryFunction BinaryFunction} I'm wrapping. */
- private BinaryFunction function = null;
+ private BinaryFunction<? super L, ? super R, ? extends T> function;
/** The parameter to pass to that function. */
- private Object param = null;
+ private L param = null;
/**
* Create a new LeftBoundFunction.
* @param function the function to adapt
* @param arg the constant argument to use
*/
- public LeftBoundFunction(BinaryFunction function, Object arg) {
+ public LeftBoundFunction(BinaryFunction<? super L, ? super R, ? extends T> function, L arg) {
+ if (function == null) {
+ throw new IllegalArgumentException("BinaryFunction argument was null");
+ }
this.function = function;
this.param = arg;
}
@@ -57,7 +60,7 @@
/**
* {@inheritDoc}
*/
- public Object evaluate(Object obj) {
+ public T evaluate(R obj) {
return function.evaluate(param, obj);
}
@@ -65,7 +68,7 @@
* {@inheritDoc}
*/
public boolean equals(Object that) {
- return that == this || (that instanceof LeftBoundFunction && equals((LeftBoundFunction) that));
+ return that == this || (that instanceof LeftBoundFunction && equals((LeftBoundFunction<?, ?, ?>) that));
}
/**
@@ -73,7 +76,7 @@
* @param that LeftBoundFunction to test
* @return boolean
*/
- public boolean equals(LeftBoundFunction that) {
+ public boolean equals(LeftBoundFunction<?, ?, ?> that) {
return null != that
&& (null == function ? null == that.function : function.equals(that.function))
&& (null == param ? null == that.param : param.equals(that.param));
@@ -108,8 +111,8 @@
* @param arg left side argument
* @return LeftBoundFunction
*/
- public static LeftBoundFunction bind(BinaryFunction function, Object arg) {
- return null == function ? null : new LeftBoundFunction(function, arg);
+ public static <L, R, T> LeftBoundFunction<L, R, T> bind(BinaryFunction<? super L, ? super R, ? extends T> function, L arg) {
+ return null == function ? null : new LeftBoundFunction<L, R, T>(function, arg);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundPredicate.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundPredicate.java Mon Jun 9 10:17:39 2008
@@ -38,19 +38,19 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class LeftBoundPredicate implements UnaryPredicate, Serializable {
+public final class LeftBoundPredicate<L, R> implements UnaryPredicate<R>, Serializable {
/** The {@link BinaryPredicate BinaryPredicate} I'm wrapping. */
- private BinaryPredicate predicate = null;
+ private BinaryPredicate<? super L, ? super R> predicate;
/** The parameter to pass to that predicate. */
- private Object param = null;
+ private L param;
/**
* Create a new LeftBoundPredicate.
* @param predicate the predicate to adapt
* @param arg the constant argument to use
*/
- public LeftBoundPredicate(BinaryPredicate predicate, Object arg) {
+ public LeftBoundPredicate(BinaryPredicate<? super L, ? super R> predicate, L arg) {
this.predicate = predicate;
this.param = arg;
}
@@ -58,7 +58,7 @@
/**
* {@inheritDoc}
*/
- public boolean test(Object obj) {
+ public boolean test(R obj) {
return predicate.test(param, obj);
}
@@ -66,7 +66,7 @@
* {@inheritDoc}
*/
public boolean equals(Object that) {
- return that == this || (that instanceof LeftBoundPredicate && equals((LeftBoundPredicate) that));
+ return that == this || (that instanceof LeftBoundPredicate && equals((LeftBoundPredicate<?, ?>) that));
}
/**
@@ -74,7 +74,7 @@
* @param that LeftBoundPredicate to test
* @return boolean
*/
- public boolean equals(LeftBoundPredicate that) {
+ public boolean equals(LeftBoundPredicate<?, ?> that) {
return null != that
&& (null == predicate ? null == that.predicate : predicate.equals(that.predicate))
&& (null == param ? null == that.param : param.equals(that.param));
@@ -109,7 +109,7 @@
* @param arg Object argument to always send as the left operand to the wrapped function
* @return LeftBoundPredicate
*/
- public static LeftBoundPredicate bind(BinaryPredicate predicate, Object arg) {
- return null == predicate ? null : new LeftBoundPredicate(predicate, arg);
+ public static <L, R> LeftBoundPredicate<L, R> bind(BinaryPredicate<? super L, ? super R> predicate, L arg) {
+ return null == predicate ? null : new LeftBoundPredicate<L, R>(predicate, arg);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundProcedure.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundProcedure.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/LeftBoundProcedure.java Mon Jun 9 10:17:39 2008
@@ -38,18 +38,18 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class LeftBoundProcedure implements UnaryProcedure, Serializable {
+public final class LeftBoundProcedure<L, R> implements UnaryProcedure<R>, Serializable {
/** The {@link BinaryProcedure BinaryProcedure} I'm wrapping. */
- private BinaryProcedure procedure = null;
+ private BinaryProcedure<? super L, ? super R> procedure;
/** The parameter to pass to that procedure. */
- private Object param = null;
+ private L param;
/**
* Create a new LeftBoundProcedure.
* @param procedure the procedure to adapt
* @param arg the constant argument to use
*/
- public LeftBoundProcedure(BinaryProcedure procedure, Object arg) {
+ public LeftBoundProcedure(BinaryProcedure<? super L, ? super R> procedure, L arg) {
this.procedure = procedure;
this.param = arg;
}
@@ -57,7 +57,7 @@
/**
* {@inheritDoc}
*/
- public void run(Object obj) {
+ public void run(R obj) {
procedure.run(param, obj);
}
@@ -65,7 +65,7 @@
* {@inheritDoc}
*/
public boolean equals(Object that) {
- return that == this || (that instanceof LeftBoundProcedure && equals((LeftBoundProcedure) that));
+ return that == this || (that instanceof LeftBoundProcedure && equals((LeftBoundProcedure<?, ?>) that));
}
/**
@@ -73,7 +73,7 @@
* @param that LeftBoundProcedure to test
* @return boolean
*/
- public boolean equals(LeftBoundProcedure that) {
+ public boolean equals(LeftBoundProcedure<?, ?> that) {
return null != that
&& (null == procedure ? null == that.procedure : procedure.equals(that.procedure))
&& (null == param ? null == that.param : param.equals(that.param));
@@ -109,8 +109,8 @@
* @param arg left side argument
* @return LeftBoundProcedure
*/
- public static LeftBoundProcedure bind(BinaryProcedure procedure, Object arg) {
- return null == procedure ? null : new LeftBoundProcedure(procedure, arg);
+ public static <L, R> LeftBoundProcedure<L, R> bind(BinaryProcedure<? super L, ? super R> procedure, L arg) {
+ return null == procedure ? null : new LeftBoundProcedure<L, R>(procedure, arg);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/PredicateFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/PredicateFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/PredicateFunction.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/PredicateFunction.java Mon Jun 9 10:17:39 2008
@@ -37,9 +37,9 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class PredicateFunction implements Function, Serializable {
+public final class PredicateFunction implements Function<Boolean>, Serializable {
/** The {@link Predicate Predicate} I'm wrapping. */
- private Predicate predicate = null;
+ private Predicate predicate;
/**
* Create a new PredicateFunction.
@@ -57,8 +57,8 @@
*
* @return a non-<code>null</code> <code>Boolean</code> instance
*/
- public Object evaluate() {
- return predicate.test() ? Boolean.TRUE : Boolean.FALSE;
+ public Boolean evaluate() {
+ return predicate.test();
}
/**
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/PredicateUnaryPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/PredicateUnaryPredicate.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/PredicateUnaryPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/PredicateUnaryPredicate.java Mon Jun 9 10:17:39 2008
@@ -38,9 +38,9 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class PredicateUnaryPredicate implements UnaryPredicate, Serializable {
+public final class PredicateUnaryPredicate<A> implements UnaryPredicate<A>, Serializable {
/** The {@link Predicate Predicate} I'm wrapping. */
- private Predicate predicate = null;
+ private Predicate predicate;
/**
* Create a new PredicateUnaryPredicate.
@@ -61,7 +61,7 @@
* {@inheritDoc}
*/
public boolean equals(Object that) {
- return that == this || (that instanceof PredicateUnaryPredicate && equals((PredicateUnaryPredicate) that));
+ return that == this || (that instanceof PredicateUnaryPredicate && equals((PredicateUnaryPredicate<?>) that));
}
/**
@@ -69,7 +69,7 @@
* @param that PredicateUnaryPredicate to test
* @return boolean
*/
- public boolean equals(PredicateUnaryPredicate that) {
+ public boolean equals(PredicateUnaryPredicate<?> that) {
return null != that && (null == predicate ? null == that.predicate : predicate.equals(that.predicate));
}
@@ -94,10 +94,10 @@
/**
* Adapt a Predicate to the UnaryPredicate interface.
* @param predicate to adapt
- * @return PredicateUnaryPredicate
+ * @return PredicateUnaryPredicate<A
*/
- public static PredicateUnaryPredicate adapt(Predicate predicate) {
- return null == predicate ? null : new PredicateUnaryPredicate(predicate);
+ public static <A> PredicateUnaryPredicate<A> adapt(Predicate predicate) {
+ return null == predicate ? null : new PredicateUnaryPredicate<A>(predicate);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/ProcedureFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/ProcedureFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/ProcedureFunction.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/ProcedureFunction.java Mon Jun 9 10:17:39 2008
@@ -38,9 +38,9 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class ProcedureFunction implements Function, Serializable {
+public final class ProcedureFunction<T> implements Function<T>, Serializable {
/** The {@link Procedure Procedure} I'm wrapping. */
- private Procedure procedure = null;
+ private Procedure procedure;
/**
* Create a new ProcedureFunction.
@@ -53,7 +53,7 @@
/**
* {@inheritDoc}
*/
- public Object evaluate() {
+ public T evaluate() {
procedure.run();
return null;
}
@@ -62,7 +62,7 @@
* {@inheritDoc}
*/
public boolean equals(Object that) {
- return that == this || (that instanceof ProcedureFunction && equals((ProcedureFunction) that));
+ return that == this || (that instanceof ProcedureFunction && equals((ProcedureFunction<?>) that));
}
/**
@@ -70,7 +70,7 @@
* @param that ProcedureFunction to test
* @return boolean
*/
- public boolean equals(ProcedureFunction that) {
+ public boolean equals(ProcedureFunction<?> that) {
return null != that && (null == procedure ? null == that.procedure : procedure.equals(that.procedure));
}
@@ -95,10 +95,10 @@
/**
* Adapt a Procedure as a Function.
* @param procedure to adapt
- * @return ProcedureFunction
+ * @return ProcedureFunction<T>
*/
- public static ProcedureFunction adapt(Procedure procedure) {
- return null == procedure ? null : new ProcedureFunction(procedure);
+ public static <T> ProcedureFunction<T> adapt(Procedure procedure) {
+ return null == procedure ? null : new ProcedureFunction<T>(procedure);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/ProcedureUnaryProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/ProcedureUnaryProcedure.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/ProcedureUnaryProcedure.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/ProcedureUnaryProcedure.java Mon Jun 9 10:17:39 2008
@@ -38,9 +38,9 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class ProcedureUnaryProcedure implements UnaryProcedure, Serializable {
+public final class ProcedureUnaryProcedure<A> implements UnaryProcedure<A>, Serializable {
/** The {@link Procedure Procedure} I'm wrapping. */
- private Procedure procedure = null;
+ private Procedure procedure;
/**
* Create a new ProcedureUnaryProcedure.
@@ -53,7 +53,7 @@
/**
* {@inheritDoc}
*/
- public void run(Object obj) {
+ public void run(A obj) {
procedure.run();
}
@@ -61,7 +61,7 @@
* {@inheritDoc}
*/
public boolean equals(Object that) {
- return that == this || (that instanceof ProcedureUnaryProcedure && equals((ProcedureUnaryProcedure) that));
+ return that == this || (that instanceof ProcedureUnaryProcedure && equals((ProcedureUnaryProcedure<?>) that));
}
/**
@@ -69,7 +69,7 @@
* @param that ProcedureUnaryProcedure to test
* @return boolean
*/
- public boolean equals(ProcedureUnaryProcedure that) {
+ public boolean equals(ProcedureUnaryProcedure<?> that) {
return null != that && (null == procedure ? null == that.procedure : procedure.equals(that.procedure));
}
@@ -94,10 +94,10 @@
/**
* Adapt a Procedure to the UnaryProcedure interface.
* @param procedure to adapt
- * @return ProcedureUnaryProcedure
+ * @return ProcedureUnaryProcedure<A>
*/
- public static ProcedureUnaryProcedure adapt(Procedure procedure) {
- return null == procedure ? null : new ProcedureUnaryProcedure(procedure);
+ public static <A> ProcedureUnaryProcedure<A> adapt(Procedure procedure) {
+ return null == procedure ? null : new ProcedureUnaryProcedure<A>(procedure);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundFunction.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundFunction.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundFunction.java Mon Jun 9 10:17:39 2008
@@ -38,17 +38,20 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class RightBoundFunction implements UnaryFunction, Serializable {
+public final class RightBoundFunction<L, R, T> implements UnaryFunction<L, T>, Serializable {
/** The {@link BinaryFunction BinaryFunction} I'm wrapping. */
- private BinaryFunction function = null;
+ private BinaryFunction<? super L, ? super R, ? extends T> function;
/** The parameter to pass to that function. */
- private Object param = null;
+ private R param;
/**
* @param function the function to adapt
* @param arg the constant argument to use
*/
- public RightBoundFunction(BinaryFunction function, Object arg) {
+ public RightBoundFunction(BinaryFunction<? super L, ? super R, ? extends T> function, R arg) {
+ if (function == null) {
+ throw new IllegalArgumentException("left-hand BinaryFunction argument was null");
+ }
this.function = function;
this.param = arg;
}
@@ -56,7 +59,7 @@
/**
* {@inheritDoc}
*/
- public Object evaluate(Object obj) {
+ public T evaluate(L obj) {
return function.evaluate(obj, param);
}
@@ -64,7 +67,7 @@
* {@inheritDoc}
*/
public boolean equals(Object that) {
- return that == this || (that instanceof RightBoundFunction && equals((RightBoundFunction) that));
+ return that == this || (that instanceof RightBoundFunction && equals((RightBoundFunction<?, ?, ?>) that));
}
/**
@@ -72,7 +75,7 @@
* @param that RightBoundFunction to test
* @return boolean
*/
- public boolean equals(RightBoundFunction that) {
+ public boolean equals(RightBoundFunction<?, ?, ?> that) {
return null != that
&& (null == function ? null == that.function : function.equals(that.function))
&& (null == param ? null == that.param : param.equals(that.param));
@@ -107,8 +110,8 @@
* @param arg Object that will always be used for the right side of the BinaryFunction delegate.
* @return RightBoundFunction
*/
- public static RightBoundFunction bind(BinaryFunction function, Object arg) {
- return null == function ? null : new RightBoundFunction(function, arg);
+ public static <L, R, T> RightBoundFunction<L, R, T> bind(BinaryFunction<? super L, ? super R, ? extends T> function, R arg) {
+ return null == function ? null : new RightBoundFunction<L, R, T>(function, arg);
}
}
Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundPredicate.java?rev=665786&r1=665785&r2=665786&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundPredicate.java (original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/RightBoundPredicate.java Mon Jun 9 10:17:39 2008
@@ -38,18 +38,18 @@
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public final class RightBoundPredicate implements UnaryPredicate, Serializable {
+public final class RightBoundPredicate<L, R> implements UnaryPredicate<L>, Serializable {
/** The {@link BinaryPredicate BinaryPredicate} I'm wrapping. */
- private BinaryPredicate predicate = null;
+ private BinaryPredicate<? super L, ? super R> predicate;
/** The parameter to pass to that predicate. */
- private Object param = null;
+ private R param;
/**
* Create a new RightBoundPredicate.
* @param predicate the predicate to adapt
* @param arg the constant argument to use
*/
- public RightBoundPredicate(BinaryPredicate predicate, Object arg) {
+ public RightBoundPredicate(BinaryPredicate<? super L, ? super R> predicate, R arg) {
this.predicate = predicate;
this.param = arg;
}
@@ -57,7 +57,7 @@
/**
* {@inheritDoc}
*/
- public boolean test(Object obj) {
+ public boolean test(L obj) {
return predicate.test(obj, param);
}
@@ -65,7 +65,7 @@
* {@inheritDoc}
*/
public boolean equals(Object that) {
- return that == this || (that instanceof RightBoundPredicate && equals((RightBoundPredicate) that));
+ return that == this || (that instanceof RightBoundPredicate && equals((RightBoundPredicate<?, ?>) that));
}
/**
@@ -73,7 +73,7 @@
* @param that RightBoundPredicate to test
* @return boolean
*/
- public boolean equals(RightBoundPredicate that) {
+ public boolean equals(RightBoundPredicate<?, ?> that) {
return null != that
&& (null == predicate ? null == that.predicate : predicate.equals(that.predicate))
&& (null == param ? null == that.param : param.equals(that.param));
@@ -108,8 +108,8 @@
* @param arg right side
* @return RightBoundPredicate
*/
- public static RightBoundPredicate bind(BinaryPredicate predicate, Object arg) {
- return null == predicate ? null : new RightBoundPredicate(predicate, arg);
+ public static <L, R> RightBoundPredicate<L, R> bind(BinaryPredicate<? super L, ? super R> predicate, R arg) {
+ return null == predicate ? null : new RightBoundPredicate<L, R>(predicate, arg);
}
}