aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/junit/runner/manipulation/Sorter.java
diff options
context:
space:
mode:
authorDavid Srbecky <dsrbecky@google.com>2021-02-24 18:09:21 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-02-24 18:09:21 +0000
commit23e304a839c5924c7ac7399076318adc511e9985 (patch)
tree81124de095a6b4a53b223d0f70cadde9744ee44a /src/main/java/org/junit/runner/manipulation/Sorter.java
parentd8911c6e959a1bda9b2b77d9aa0d35eea7a401f9 (diff)
parent565f36d28118dce0c0a08fe71924dcd25e039022 (diff)
downloadjunit-23e304a839c5924c7ac7399076318adc511e9985.tar.gz
Merge changes from topic "revert-1601635-AIQYZOHWTP" am: 565f36d281
Original change: https://android-review.googlesource.com/c/platform/external/junit/+/1605377 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I1b6b1c8147b46e6c2a0ebd81a22edbb370082ded
Diffstat (limited to 'src/main/java/org/junit/runner/manipulation/Sorter.java')
-rw-r--r--src/main/java/org/junit/runner/manipulation/Sorter.java54
1 files changed, 6 insertions, 48 deletions
diff --git a/src/main/java/org/junit/runner/manipulation/Sorter.java b/src/main/java/org/junit/runner/manipulation/Sorter.java
index 4b5274c..20192d0 100644
--- a/src/main/java/org/junit/runner/manipulation/Sorter.java
+++ b/src/main/java/org/junit/runner/manipulation/Sorter.java
@@ -1,21 +1,16 @@
package org.junit.runner.manipulation;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
import java.util.Comparator;
-import java.util.List;
import org.junit.runner.Description;
/**
* A <code>Sorter</code> orders tests. In general you will not need
- * to use a <code>Sorter</code> directly. Instead, use
- * {@link org.junit.runner.Request#sortWith(Comparator)}.
+ * to use a <code>Sorter</code> directly. Instead, use {@link org.junit.runner.Request#sortWith(Comparator)}.
*
* @since 4.0
*/
-public class Sorter extends Ordering implements Comparator<Description> {
+public class Sorter implements Comparator<Description> {
/**
* NULL is a <code>Sorter</code> that leaves elements in an undefined order
*/
@@ -32,26 +27,17 @@ public class Sorter extends Ordering implements Comparator<Description> {
* to sort tests
*
* @param comparator the {@link Comparator} to use when sorting tests
- * @since 4.0
*/
public Sorter(Comparator<Description> comparator) {
this.comparator = comparator;
}
/**
- * Sorts the tests in <code>target</code> using <code>comparator</code>.
- *
- * @since 4.0
+ * Sorts the test in <code>runner</code> using <code>comparator</code>
*/
- @Override
- public void apply(Object target) {
- /*
- * Note that all runners that are Orderable are also Sortable (because
- * Orderable extends Sortable). Sorting is more efficient than ordering,
- * so we override the parent behavior so we sort instead.
- */
- if (target instanceof Sortable) {
- Sortable sortable = (Sortable) target;
+ public void apply(Object object) {
+ if (object instanceof Sortable) {
+ Sortable sortable = (Sortable) object;
sortable.sort(this);
}
}
@@ -59,32 +45,4 @@ public class Sorter extends Ordering implements Comparator<Description> {
public int compare(Description o1, Description o2) {
return comparator.compare(o1, o2);
}
-
- /**
- * {@inheritDoc}
- *
- * @since 4.13
- */
- @Override
- protected final List<Description> orderItems(Collection<Description> descriptions) {
- /*
- * In practice, we will never get here--Sorters do their work in the
- * compare() method--but the Liskov substitution principle demands that
- * we obey the general contract of Orderable. Luckily, it's trivial to
- * implement.
- */
- List<Description> sorted = new ArrayList<Description>(descriptions);
- Collections.sort(sorted, this); // Note: it would be incorrect to pass in "comparator"
- return sorted;
- }
-
- /**
- * {@inheritDoc}
- *
- * @since 4.13
- */
- @Override
- boolean validateOrderingIsCorrect() {
- return false;
- }
}