1 package org.junit.runner.manipulation;
2
3 import java.util.Comparator;
4
5 import org.junit.runner.Description;
6
7
8
9
10
11
12
13 public class Sorter implements Comparator<Description> {
14
15
16
17 public static final Sorter NULL = new Sorter(new Comparator<Description>() {
18 public int compare(Description o1, Description o2) {
19 return 0;
20 }
21 });
22
23 private final Comparator<Description> comparator;
24
25
26
27
28
29
30
31 public Sorter(Comparator<Description> comparator) {
32 this.comparator = comparator;
33 }
34
35
36
37
38 public void apply(Object object) {
39 if (object instanceof Sortable) {
40 Sortable sortable = (Sortable) object;
41 sortable.sort(this);
42 }
43 }
44
45 public int compare(Description o1, Description o2) {
46 return comparator.compare(o1, o2);
47 }
48 }