carbidecpp20devenv/plugins/org.eclipse.test.source_3.3.0.v20080507/src/org.junit4_4.3.1/junitsrc/org/junit/runner/manipulation/Sorter.java
changeset 1 82d1d1de1a01
equal deleted inserted replaced
-1:000000000000 1:82d1d1de1a01
       
     1 package org.junit.runner.manipulation;
       
     2 
       
     3 import java.util.Comparator;
       
     4 
       
     5 import org.junit.runner.Description;
       
     6 import org.junit.runner.Runner;
       
     7 
       
     8 /**
       
     9  * A <code>Sorter</code> orders tests. In general you will not need
       
    10  * to use a <code>Sorter</code> directly. Instead, use {@link org.junit.runner.Request#sortWith(Comparator)}.
       
    11  * 
       
    12  * 
       
    13  */
       
    14 public class Sorter implements Comparator<Description> {
       
    15 	private final Comparator<Description> fComparator;
       
    16 
       
    17 	/**
       
    18 	 * Creates a <code>Sorter</code> that uses <code>comparator</code>
       
    19 	 * to sort tests
       
    20 	 * @param comparator the {@link Comparator} to use when sorting tests
       
    21 	 */
       
    22 	public Sorter(Comparator<Description> comparator) {
       
    23 		fComparator= comparator;
       
    24 	}
       
    25 
       
    26 	/**
       
    27 	 * Sorts the test in <code>runner</code> using <code>comparator</code>
       
    28 	 * @param runner
       
    29 	 */
       
    30 	public void apply(Runner runner) {
       
    31 		if (runner instanceof Sortable) {
       
    32 			Sortable sortable = (Sortable) runner;
       
    33 			sortable.sort(this);
       
    34 		}
       
    35 	}
       
    36 
       
    37 	/** @inheritDoc */
       
    38 	public int compare(Description o1, Description o2) {
       
    39 		return fComparator.compare(o1, o2);
       
    40 	}
       
    41 }