Author: mbenson
Date: Tue Jun 10 13:46:08 2008
New Revision: 666315
URL: http://svn.apache.org/viewvc?rev=666315&view=rev
Log:
make instance() methods conform to the approach adopted in the genericization
of [functor]: yield a parameterized instance
Modified:
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/IsNotEquivalent.java
Modified:
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsEquivalent.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsEquivalent.java?rev=666315&r1=666314&r2=666315&view=diff
==============================================================================
---
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsEquivalent.java
(original)
+++
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsEquivalent.java
Tue Jun 10 13:46:08 2008
@@ -37,12 +37,23 @@
*
*/
public final class IsEquivalent<T> implements BinaryPredicate<T, T>,
Serializable {
- private static final IsEquivalent<Comparable<?>> COMPARABLE_INSTANCE = new
IsEquivalent<Comparable<?>>(
- ComparableComparator.instance());
+ /**
+ * Basic IsEquivalent instance.
+ */
+ @SuppressWarnings("unchecked")
+ public static final IsEquivalent<Comparable<?>> INSTANCE =
IsEquivalent.<Comparable<?>> instance();
private Comparator<? super T> comparator;
/**
+ * Create a new IsEquivalent.
+ */
+ @SuppressWarnings("unchecked")
+ public IsEquivalent() {
+ this(ComparableComparator.INSTANCE);
+ }
+
+ /**
* Construct an <code>IsEquivalent</code> [EMAIL PROTECTED]
BinaryPredicate predicate}
* for the given [EMAIL PROTECTED] Comparator Comparator}.
*
@@ -102,10 +113,12 @@
/**
* Get a basic IsEquivalent instance.
- * @return IsEquivalent
+ * @param T
+ * @return IsEquivalent<T>
*/
- public static final IsEquivalent<Comparable<?>> instance() {
- return COMPARABLE_INSTANCE;
+ @SuppressWarnings("unchecked")
+ public static final <T extends Comparable<?>> IsEquivalent<T> instance() {
+ return new IsEquivalent<T>(ComparableComparator.INSTANCE);
}
/**
@@ -113,7 +126,7 @@
* @param right argument
* @return UnaryPredicate
*/
- public static final UnaryPredicate<Comparable<?>> instance(Comparable<?>
right) {
+ public static final <T extends Comparable<?>> UnaryPredicate<T> instance(T
right) {
return RightBoundPredicate.bind(instance(), right);
}
Modified:
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsNotEquivalent.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsNotEquivalent.java?rev=666315&r1=666314&r2=666315&view=diff
==============================================================================
---
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsNotEquivalent.java
(original)
+++
commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/comparator/IsNotEquivalent.java
Tue Jun 10 13:46:08 2008
@@ -37,11 +37,22 @@
*
*/
public final class IsNotEquivalent<T> implements BinaryPredicate<T, T>,
Serializable {
- private static final IsNotEquivalent<Comparable<?>> COMPARABLE_INSTANCE =
new IsNotEquivalent<Comparable<?>>(ComparableComparator.instance());
+ /**
+ * Basic IsNotEquivalent instance.
+ */
+ public static final IsNotEquivalent<Comparable<?>> INSTANCE =
IsNotEquivalent.<Comparable<?>>instance();
private Comparator<? super T> comparator = null;
/**
+ * Create a new IsNotEquivalent.
+ */
+ @SuppressWarnings("unchecked")
+ public IsNotEquivalent() {
+ this(ComparableComparator.INSTANCE);
+ }
+
+ /**
* Construct a <code>IsNotEquivalent</code> [EMAIL PROTECTED]
BinaryPredicate predicate}
* for the given [EMAIL PROTECTED] Comparator Comparator}.
*
@@ -103,8 +114,9 @@
* Get an IsNotEquivalent instance.
* @return IsNotEquivalent
*/
- public static final IsNotEquivalent<Comparable<?>> instance() {
- return COMPARABLE_INSTANCE;
+ @SuppressWarnings("unchecked")
+ public static final <T extends Comparable<?>> IsNotEquivalent<T>
instance() {
+ return new IsNotEquivalent<T>(ComparableComparator.INSTANCE);
}
/**
@@ -112,7 +124,7 @@
* @param right Comparable against which UnaryPredicate arguments will be
compared.
* @return UnaryPredicate
*/
- public static final UnaryPredicate<Comparable<?>> instance(Comparable<?>
right) {
+ public static final <T extends Comparable<?>> UnaryPredicate<T> instance(T
right) {
return RightBoundPredicate.bind(instance(), right);
}