From a68c67c121f870bec52b6a869014048bae68d808 Mon Sep 17 00:00:00 2001
From: Sebastian Bazley
Date: Mon, 18 Oct 2010 16:45:29 +0000
Subject: [PATCH] Tab and trailing space removal
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1023897 13f79535-47bb-0310-9956-ffa450edef68
---
.../apache/commons/collections/ListUtils.java | 4 +-
.../functors/ComparatorPredicate.java | 206 +++++++++---------
.../commons/collections/TestListUtils.java | 18 +-
3 files changed, 114 insertions(+), 114 deletions(-)
diff --git a/src/java/org/apache/commons/collections/ListUtils.java b/src/java/org/apache/commons/collections/ListUtils.java
index cc244ca6e..0ad4e2e44 100644
--- a/src/java/org/apache/commons/collections/ListUtils.java
+++ b/src/java/org/apache/commons/collections/ListUtils.java
@@ -75,8 +75,8 @@ public class ListUtils {
List extends E> smaller = list1;
List extends E> larger = list2;
if (list1.size() > list2.size()) {
- smaller = list2;
- larger = list1;
+ smaller = list2;
+ larger = list1;
}
HashSet hashSet = new HashSet(smaller);
diff --git a/src/java/org/apache/commons/collections/functors/ComparatorPredicate.java b/src/java/org/apache/commons/collections/functors/ComparatorPredicate.java
index c6f73f2b3..3ed309c09 100644
--- a/src/java/org/apache/commons/collections/functors/ComparatorPredicate.java
+++ b/src/java/org/apache/commons/collections/functors/ComparatorPredicate.java
@@ -24,54 +24,54 @@ import org.apache.commons.collections.Predicate;
/**
* Predicate that compares the input object with the one stored in the predicate using a comparator.
* In addition, the comparator result can be evaluated in accordance to a supplied criterion value.
- *
+ *
* In order to demonstrate the use of the predicate, the following variables are declared:
*
*
* Integer ONE = new Integer(1);
* Integer TWO = new Integer(2);
- *
+ *
* Comparator comparator = new Comparator() {
*
* public int compare(Object first, Object second) {
- * return ((Integer) second) - ((Integer) first);
- * }
+ * return ((Integer) second) - ((Integer) first);
+ * }
*
* };
*
- *
+ *
* Using the declared variables, the ComparatorPredicate
can be used used in the
- * following way:
- *
+ * following way:
+ *
*
- * ComparatorPredicate.getInstance(ONE, comparator).evaluate(TWO);
- *
- *
+ * ComparatorPredicate.getInstance(ONE, comparator).evaluate(TWO);
+ *
+ *
* The input variable TWO
in compared to the stored variable ONE
using
* the supplied comparator
. This is the default usage of the predicate and will return
- * true
if the underlying comparator returns 0
. In addition to the default
- * usage of the predicate, it is possible to evaluate the comparator's result in several ways. The
+ * true
if the underlying comparator returns 0
. In addition to the default
+ * usage of the predicate, it is possible to evaluate the comparator's result in several ways. The
* following {@link Criterion} enumeration values are provided by the predicate:
*
- *
+ *
*
* - EQUAL
* - GREATER
* - GREATER_OR_EQUAL
* - LESS
* - LESS_OR_EQUAL
- *
- *
+ *
+ *
* The following examples demonstrates how these constants can be used in order to manipulate the
* evaluation of a comparator result.
- *
+ *
*
* ComparatorPredicate.getInstance(ONE, comparator, ComparatorPredicate.Criterion.GREATER).evaluate(TWO);
*
- *
+ *
* The input variable TWO is compared to the stored variable ONE using the supplied comparator
* using the GREATER
evaluation criterion constant. This instructs the predicate to
- * return true
if the comparator returns a value greater than 0
.
+ * return true
if the comparator returns a value greater than 0
.
*
* @since Commons Collections 4.0
* @version $Revision: $ $Date: $
@@ -83,106 +83,106 @@ public class ComparatorPredicate implements Predicate, Serializable {
private static final long serialVersionUID = -1863209236504077399L;
public enum Criterion {
- EQUAL, GREATER, LESS, GREATER_OR_EQUAL, LESS_OR_EQUAL,
+ EQUAL, GREATER, LESS, GREATER_OR_EQUAL, LESS_OR_EQUAL,
}
- // Instance variables:
-
- /** The internal object to compare with */
- private final T object;
+ // Instance variables:
- /** The comparator to use for comparison */
- private final Comparator comparator;
+ /** The internal object to compare with */
+ private final T object;
- /** The comparison evaluation criterion to use */
- private final Criterion criterion;
+ /** The comparator to use for comparison */
+ private final Comparator comparator;
- /**
- * Factory to create the comparator predicate
- *
- * @param object the object to compare to
- * @param comparator the comparator to use for comparison
- * @return the predicate
- * @throws IllegalArgumentException if comparator is null
- */
- public static Predicate getInstance(T object, Comparator comparator) {
- return getInstance(object, comparator, Criterion.EQUAL);
- }
+ /** The comparison evaluation criterion to use */
+ private final Criterion criterion;
- /**
- * Factory to create the comparator predicate
- *
- * @param object the object to compare to
- * @param comparator the comparator to use for comparison
- * @param criterion the criterion to use to evaluate comparison
- * @return the predicate
- * @throws IllegalArgumentException if comparator is null of criterion is invalid
- */
- public static Predicate getInstance(T object, Comparator comparator, Criterion criterion) {
+ /**
+ * Factory to create the comparator predicate
+ *
+ * @param object the object to compare to
+ * @param comparator the comparator to use for comparison
+ * @return the predicate
+ * @throws IllegalArgumentException if comparator is null
+ */
+ public static Predicate getInstance(T object, Comparator comparator) {
+ return getInstance(object, comparator, Criterion.EQUAL);
+ }
+
+ /**
+ * Factory to create the comparator predicate
+ *
+ * @param object the object to compare to
+ * @param comparator the comparator to use for comparison
+ * @param criterion the criterion to use to evaluate comparison
+ * @return the predicate
+ * @throws IllegalArgumentException if comparator is null of criterion is invalid
+ */
+ public static Predicate getInstance(T object, Comparator comparator, Criterion criterion) {
if (comparator == null) {
throw new IllegalArgumentException("Comparator must not be null.");
}
if (criterion == null) {
throw new IllegalArgumentException("Criterion must not be null.");
}
- return new ComparatorPredicate(object, comparator, criterion);
- }
+ return new ComparatorPredicate(object, comparator, criterion);
+ }
- /**
- * Constructor that performs no validation.
- * Use getInstance
if you want.
- *
- * @param object the object to compare to
- * @param comparator the comparator to use for comparison
- * @param criterion the criterion to use to evaluate comparison
- */
- public ComparatorPredicate(T object, Comparator comparator, Criterion criterion) {
- super();
- this.object = object;
- this.comparator = comparator;
- this.criterion = criterion;
- }
+ /**
+ * Constructor that performs no validation.
+ * Use getInstance
if you want.
+ *
+ * @param object the object to compare to
+ * @param comparator the comparator to use for comparison
+ * @param criterion the criterion to use to evaluate comparison
+ */
+ public ComparatorPredicate(T object, Comparator comparator, Criterion criterion) {
+ super();
+ this.object = object;
+ this.comparator = comparator;
+ this.criterion = criterion;
+ }
- /**
- * Evaluates the predicate. The predicate evaluates to true
in the following cases:
- *
- *
- * comparator.compare(object, input) == 0 && criterion == EQUAL
- * comparator.compare(object, input) < 0 && criterion == LESS
- * comparator.compare(object, input) > 0 && criterion == GREATER
- * comparator.compare(object, input) >= 0 && criterion == GREATER_OR_EQUAL
- * comparator.compare(object, input) <= 0 && criterion == LESS_OR_EQUAL
- *
- *
- * @see org.apache.commons.collections.Predicate#evaluate(java.lang.Object)
- * @see java.util.Comparator#compare(java.lang.Object first, java.lang.Object second)
- *
- * @throws IllegalStateException if the criterion is invalid (really not possible)
- */
- public boolean evaluate(T target) {
+ /**
+ * Evaluates the predicate. The predicate evaluates to true
in the following cases:
+ *
+ *
+ * comparator.compare(object, input) == 0 && criterion == EQUAL
+ * comparator.compare(object, input) < 0 && criterion == LESS
+ * comparator.compare(object, input) > 0 && criterion == GREATER
+ * comparator.compare(object, input) >= 0 && criterion == GREATER_OR_EQUAL
+ * comparator.compare(object, input) <= 0 && criterion == LESS_OR_EQUAL
+ *
+ *
+ * @see org.apache.commons.collections.Predicate#evaluate(java.lang.Object)
+ * @see java.util.Comparator#compare(java.lang.Object first, java.lang.Object second)
+ *
+ * @throws IllegalStateException if the criterion is invalid (really not possible)
+ */
+ public boolean evaluate(T target) {
- boolean result = false;
- int comparison = comparator.compare(object, target);
+ boolean result = false;
+ int comparison = comparator.compare(object, target);
switch (criterion) {
- case EQUAL:
- result = (comparison == 0);
- break;
- case GREATER:
- result = (comparison > 0);
- break;
- case LESS:
- result = (comparison < 0);
- break;
- case GREATER_OR_EQUAL:
- result = (comparison >= 0);
- break;
- case LESS_OR_EQUAL:
- result = (comparison <= 0);
- break;
- default:
- throw new IllegalStateException("The current criterion '" + criterion + "' is invalid.");
- }
+ case EQUAL:
+ result = (comparison == 0);
+ break;
+ case GREATER:
+ result = (comparison > 0);
+ break;
+ case LESS:
+ result = (comparison < 0);
+ break;
+ case GREATER_OR_EQUAL:
+ result = (comparison >= 0);
+ break;
+ case LESS_OR_EQUAL:
+ result = (comparison <= 0);
+ break;
+ default:
+ throw new IllegalStateException("The current criterion '" + criterion + "' is invalid.");
+ }
- return result;
- }
+ return result;
+ }
}
diff --git a/src/test/org/apache/commons/collections/TestListUtils.java b/src/test/org/apache/commons/collections/TestListUtils.java
index c69652033..ebf030cbc 100644
--- a/src/test/org/apache/commons/collections/TestListUtils.java
+++ b/src/test/org/apache/commons/collections/TestListUtils.java
@@ -117,15 +117,15 @@ public class TestListUtils extends BulkTest {
* Tests intersecting two lists in different orders.
*/
public void testIntersectionOrderInsensitivity() {
- List one = new ArrayList();
- List two = new ArrayList();
- one.add("a");
- one.add("b");
- two.add("a");
- two.add("a");
- two.add("b");
- two.add("b");
- assertEquals(ListUtils.intersection(one,two),ListUtils.intersection(two, one));
+ List one = new ArrayList();
+ List two = new ArrayList();
+ one.add("a");
+ one.add("b");
+ two.add("a");
+ two.add("a");
+ two.add("b");
+ two.add("b");
+ assertEquals(ListUtils.intersection(one,two),ListUtils.intersection(two, one));
}
public void testPredicatedList() {