3838public class DefaultRunOrderCalculator
3939 implements RunOrderCalculator
4040{
41- private final Comparator <Class > sortOrder ;
41+ private final Comparator <Class <?> > sortOrder ;
4242
4343 private final RunOrder [] runOrder ;
4444
@@ -55,12 +55,7 @@ public DefaultRunOrderCalculator( RunOrderParameters runOrderParameters, int thr
5555 this .runOrder = runOrderParameters .getRunOrder ();
5656 this .sortOrder = this .runOrder .length > 0 ? getSortOrderComparator ( this .runOrder [0 ] ) : null ;
5757 Long runOrderRandomSeed = runOrderParameters .getRunOrderRandomSeed ();
58- if ( runOrderRandomSeed == null )
59- {
60- runOrderRandomSeed = System .nanoTime ();
61- runOrderParameters .setRunOrderRandomSeed ( runOrderRandomSeed );
62- }
63- this .random = new Random ( runOrderRandomSeed );
58+ this .random = new Random ( runOrderRandomSeed == null ? System .nanoTime () : runOrderRandomSeed );
6459 }
6560
6661 @ Override
@@ -102,11 +97,11 @@ else if ( RunOrder.BALANCED.equals( runOrder ) )
10297 }
10398 else if ( sortOrder != null )
10499 {
105- Collections .sort ( testClasses , sortOrder );
100+ testClasses .sort ( sortOrder );
106101 }
107102 }
108103
109- private Comparator <Class > getSortOrderComparator ( RunOrder runOrder )
104+ private static Comparator <Class <?> > getSortOrderComparator ( RunOrder runOrder )
110105 {
111106 if ( RunOrder .ALPHABETICAL .equals ( runOrder ) )
112107 {
@@ -127,27 +122,13 @@ else if ( RunOrder.HOURLY.equals( runOrder ) )
127122 }
128123 }
129124
130- private Comparator <Class > getReverseAlphabeticalComparator ()
125+ private static Comparator <Class <?> > getReverseAlphabeticalComparator ()
131126 {
132- return new Comparator <Class >()
133- {
134- @ Override
135- public int compare ( Class o1 , Class o2 )
136- {
137- return o2 .getName ().compareTo ( o1 .getName () );
138- }
139- };
127+ return ( o1 , o2 ) -> o2 .getName ().compareTo ( o1 .getName () );
140128 }
141129
142- private Comparator <Class > getAlphabeticalComparator ()
130+ private static Comparator <Class <?> > getAlphabeticalComparator ()
143131 {
144- return new Comparator <Class >()
145- {
146- @ Override
147- public int compare ( Class o1 , Class o2 )
148- {
149- return o1 .getName ().compareTo ( o2 .getName () );
150- }
151- };
132+ return Comparator .comparing ( Class ::getName );
152133 }
153134}
0 commit comments