1 /*
   2  * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**
  25  * @test
  26  * @bug 8134512
  27  * @summary Comparator default method tests
  28  * @run testng BasicTest
  29  */
  30 
  31 import org.testng.annotations.DataProvider;
  32 import org.testng.annotations.Test;
  33 
  34 import java.util.Arrays;
  35 import java.util.ArrayList;
  36 import java.util.Collections;
  37 import java.util.Comparator;
  38 import java.util.List;
  39 import java.util.function.Function;
  40 import java.util.function.ToIntFunction;
  41 import java.util.function.ToLongFunction;
  42 import java.util.function.ToDoubleFunction;
  43 
  44 import static org.testng.Assert.assertEquals;
  45 import static org.testng.Assert.assertTrue;
  46 import static org.testng.Assert.fail;
  47 
  48 @Test(groups = "unit")
  49 public class BasicTest {
  50     private static class Thing {
  51         public final int intField;
  52         public final long longField;
  53         public final double doubleField;
  54         public final String stringField;
  55 
  56         private Thing(int intField, long longField, double doubleField, String stringField) {
  57             this.intField = intField;
  58             this.longField = longField;
  59             this.doubleField = doubleField;
  60             this.stringField = stringField;
  61         }
  62 
  63         public int getIntField() {
  64             return intField;
  65         }
  66 
  67         public long getLongField() {
  68             return longField;
  69         }
  70 
  71         public double getDoubleField() {
  72             return doubleField;
  73         }
  74 
  75         public String getStringField() {
  76             return stringField;
  77         }
  78     }
  79 
  80     private final int[] intValues = { -2, -2, -1, -1, 0, 0, 1, 1, 2, 2 };
  81     private final long[] longValues = { -2, -2, -1, -1, 0, 0, 1, 1, 2, 2 };
  82     private final double[] doubleValues = { -2, -2, -1, -1, 0, 0, 1, 1, 2, 2 };
  83     private final String[] stringValues = { "a", "a", "b", "b", "c", "c", "d", "d", "e", "e" };
  84     private final int[] comparisons = { 0, -1, 0, -1, 0, -1, 0, -1, 0 };
  85 
  86     private<T> void assertComparisons(T[] things, Comparator<T> comp, int[] comparisons) {
  87         for (int i=0; i<comparisons.length; i++) {
  88             assertEquals(comparisons.length + 1, things.length);
  89             assertEquals(comparisons[i], comp.compare(things[i], things[i+1]));
  90             assertEquals(-comparisons[i], comp.compare(things[i+1], things[i]));
  91         }
  92     }
  93 
  94     public void testIntComparator() {
  95         Thing[] things = new Thing[intValues.length];
  96         for (int i=0; i<intValues.length; i++)
  97             things[i] = new Thing(intValues[i], 0L, 0.0, null);
  98         Comparator<Thing> comp = Comparator.comparingInt(new ToIntFunction<Thing>() {
  99             @Override
 100             public int applyAsInt(Thing thing) {
 101                 return thing.getIntField();
 102             }
 103         });
 104 
 105         assertComparisons(things, comp, comparisons);
 106     }
 107 
 108     public void testLongComparator() {
 109         Thing[] things = new Thing[longValues.length];
 110         for (int i=0; i<longValues.length; i++)
 111             things[i] = new Thing(0, longValues[i], 0.0, null);
 112         Comparator<Thing> comp = Comparator.comparingLong(new ToLongFunction<Thing>() {
 113             @Override
 114             public long applyAsLong(Thing thing) {
 115                 return thing.getLongField();
 116             }
 117         });
 118 
 119         assertComparisons(things, comp, comparisons);
 120     }
 121 
 122     public void testDoubleComparator() {
 123         Thing[] things = new Thing[doubleValues.length];
 124         for (int i=0; i<doubleValues.length; i++)
 125             things[i] = new Thing(0, 0L, doubleValues[i], null);
 126         Comparator<Thing> comp = Comparator.comparingDouble(new ToDoubleFunction<Thing>() {
 127             @Override
 128             public double applyAsDouble(Thing thing) {
 129                 return thing.getDoubleField();
 130             }
 131         });
 132 
 133         assertComparisons(things, comp, comparisons);
 134     }
 135 
 136     public void testComparing() {
 137         Thing[] things = new Thing[doubleValues.length];
 138         for (int i=0; i<doubleValues.length; i++)
 139             things[i] = new Thing(0, 0L, 0.0, stringValues[i]);
 140         Comparator<Thing> comp = Comparator.comparing(new Function<Thing, String>() {
 141             @Override
 142             public String apply(Thing thing) {
 143                 return thing.getStringField();
 144             }
 145         });
 146 
 147         assertComparisons(things, comp, comparisons);
 148     }
 149 
 150     public void testNaturalOrderComparator() {
 151         Comparator<String> comp = Comparator.naturalOrder();
 152 
 153         assertComparisons(stringValues, comp, comparisons);
 154     }
 155 
 156     public void testReverseComparator() {
 157         Comparator<String> cmpr = Comparator.reverseOrder();
 158         Comparator<String> cmp = cmpr.reversed();
 159 
 160         assertEquals(cmp.reversed(), cmpr);
 161         assertEquals(0, cmp.compare("a", "a"));
 162         assertEquals(0, cmpr.compare("a", "a"));
 163         assertTrue(cmp.compare("a", "b") < 0);
 164         assertTrue(cmpr.compare("a", "b") > 0);
 165         assertTrue(cmp.compare("b", "a") > 0);
 166         assertTrue(cmpr.compare("b", "a") < 0);
 167     }
 168 
 169     public void testReverseComparator2() {
 170         Comparator<String> cmp = (s1, s2) -> s1.length() - s2.length();
 171         Comparator<String> cmpr = cmp.reversed();
 172 
 173         assertEquals(cmpr.reversed(), cmp);
 174         assertEquals(0, cmp.compare("abc", "def"));
 175         assertEquals(0, cmpr.compare("abc", "def"));
 176         assertTrue(cmp.compare("abcd", "def") > 0);
 177         assertTrue(cmpr.compare("abcd", "def") < 0);
 178         assertTrue(cmp.compare("abc", "defg") < 0);
 179         assertTrue(cmpr.compare("abc", "defg") > 0);
 180     }
 181 
 182     private <T> void assertComparison(Comparator<T> cmp, T less, T greater) {
 183         assertTrue(cmp.compare(less, greater) < 0, "less");
 184         assertTrue(cmp.compare(less, less) == 0, "equal");
 185         assertTrue(cmp.compare(greater, greater) == 0, "equal");
 186         assertTrue(cmp.compare(greater, less) > 0, "greater");
 187     }
 188 
 189     private static class People {
 190         final String firstName;
 191         final String lastName;
 192         final int age;
 193 
 194         People(String first, String last, int age) {
 195             firstName = first;
 196             lastName = last;
 197             this.age = age;
 198         }
 199 
 200         String getFirstName() { return firstName; }
 201         String getLastName() { return lastName; }
 202         int getAge() { return age; }
 203         long getAgeAsLong() { return (long) age; };
 204         double getAgeAsDouble() { return (double) age; };
 205     }
 206 
 207     private final People people[] = {
 208         new People("John", "Doe", 34),
 209         new People("Mary", "Doe", 30),
 210         new People("Maria", "Doe", 14),
 211         new People("Jonah", "Doe", 10),
 212         new People("John", "Cook", 54),
 213         new People("Mary", "Cook", 50),
 214         new People("Mary", null, 25),
 215         new People("John", null, 27)
 216     };
 217 
 218     public void testComparatorDefaultMethods() {
 219         Comparator<People> cmp = Comparator.comparing(People::getFirstName);
 220         Comparator<People> cmp2 = Comparator.comparing(People::getLastName);
 221         // reverseOrder
 222         assertComparison(cmp.reversed(), people[1], people[0]);
 223         // thenComparing(Comparator)
 224         assertComparison(cmp.thenComparing(cmp2), people[0], people[1]);
 225         assertComparison(cmp.thenComparing(cmp2), people[4], people[0]);
 226         // thenComparing(Function)
 227         assertComparison(cmp.thenComparing(People::getLastName), people[0], people[1]);
 228         assertComparison(cmp.thenComparing(People::getLastName), people[4], people[0]);
 229         // thenComparing(ToIntFunction)
 230         assertComparison(cmp.thenComparingInt(People::getAge), people[0], people[1]);
 231         assertComparison(cmp.thenComparingInt(People::getAge), people[1], people[5]);
 232         // thenComparing(ToLongFunction)
 233         assertComparison(cmp.thenComparingLong(People::getAgeAsLong), people[0], people[1]);
 234         assertComparison(cmp.thenComparingLong(People::getAgeAsLong), people[1], people[5]);
 235         // thenComparing(ToDoubleFunction)
 236         assertComparison(cmp.thenComparingDouble(People::getAgeAsDouble), people[0], people[1]);
 237         assertComparison(cmp.thenComparingDouble(People::getAgeAsDouble), people[1], people[5]);
 238     }
 239 
 240 
 241     public void testNullsFirst() {
 242         Comparator<String> strcmp = Comparator.nullsFirst(Comparator.naturalOrder());
 243         Comparator<People> cmp = Comparator.comparing(People::getLastName, strcmp)
 244                                            .thenComparing(People::getFirstName, strcmp);
 245         // Mary.null vs Mary.Cook - solve by last name
 246         assertComparison(cmp, people[6], people[5]);
 247         // John.null vs Mary.null - solve by first name
 248         assertComparison(cmp, people[7], people[6]);
 249 
 250         // More than one thenComparing
 251         strcmp = Comparator.nullsFirst(Comparator.comparingInt(String::length)
 252                                                  .thenComparing(String.CASE_INSENSITIVE_ORDER));
 253         assertComparison(strcmp, null, "abc");
 254         assertComparison(strcmp, "ab", "abc");
 255         assertComparison(strcmp, "abc", "def");
 256         assertEquals(0, strcmp.compare("abc", "ABC"));
 257 
 258         // Ensure reverse still handle null properly
 259         Comparator<String> strcmp2 = strcmp.reversed().thenComparing(Comparator.naturalOrder());
 260         assertComparison(strcmp2, "abc", null);
 261         assertComparison(strcmp2, "abc", "ab");
 262         assertComparison(strcmp2, "def", "abc");
 263         assertComparison(strcmp2, "ABC", "abc");
 264 
 265         // Considering non-null values to be equal
 266         Comparator<String> blind = Comparator.nullsFirst(null);
 267         assertComparison(blind, null, "abc");
 268         assertEquals(0, blind.compare("abc", "def"));
 269         // reverse still consider non-null values to be equal
 270         strcmp = blind.reversed();
 271         assertComparison(strcmp, "abc", null);
 272         assertEquals(0, strcmp.compare("abc", "def"));
 273         // chain with another comparator to compare non-nulls
 274         strcmp = blind.thenComparing(Comparator.naturalOrder());
 275         assertComparison(strcmp, null, "abc");
 276         assertComparison(strcmp, "abc", "def");
 277     }
 278 
 279     public void testNullsLast() {
 280         Comparator<String> strcmp = Comparator.nullsLast(Comparator.naturalOrder());
 281         Comparator<People> cmp = Comparator.comparing(People::getLastName, strcmp)
 282                                            .thenComparing(People::getFirstName, strcmp);
 283         // Mary.null vs Mary.Cook - solve by last name
 284         assertComparison(cmp, people[5], people[6]);
 285         // John.null vs Mary.null - solve by first name
 286         assertComparison(cmp, people[7], people[6]);
 287 
 288         // More than one thenComparing
 289         strcmp = Comparator.nullsLast(Comparator.comparingInt(String::length)
 290                                                 .thenComparing(String.CASE_INSENSITIVE_ORDER));
 291         assertComparison(strcmp, "abc", null);
 292         assertComparison(strcmp, "ab", "abc");
 293         assertComparison(strcmp, "abc", "def");
 294 
 295         // Ensure reverse still handle null properly
 296         Comparator<String> strcmp2 = strcmp.reversed().thenComparing(Comparator.naturalOrder());
 297         assertComparison(strcmp2, null, "abc");
 298         assertComparison(strcmp2, "abc", "ab");
 299         assertComparison(strcmp2, "def", "abc");
 300         assertComparison(strcmp2, "ABC", "abc");
 301 
 302         // Considering non-null values to be equal
 303         Comparator<String> blind = Comparator.nullsLast(null);
 304         assertComparison(blind, "abc", null);
 305         assertEquals(0, blind.compare("abc", "def"));
 306         // reverse still consider non-null values to be equal
 307         strcmp = blind.reversed();
 308         assertComparison(strcmp, null, "abc");
 309         assertEquals(0, strcmp.compare("abc", "def"));
 310         // chain with another comparator to compare non-nulls
 311         strcmp = blind.thenComparing(Comparator.naturalOrder());
 312         assertComparison(strcmp, "abc", null);
 313         assertComparison(strcmp, "abc", "def");
 314     }
 315 
 316     public void testComposeComparator() {
 317         // Longer string in front
 318         Comparator<String> first = (s1, s2) -> s2.length() - s1.length();
 319         Comparator<String> second = Comparator.naturalOrder();
 320         Comparator<String> composed = first.thenComparing(second);
 321 
 322         assertTrue(composed.compare("abcdefg", "abcdef") < 0);
 323         assertTrue(composed.compare("abcdef", "abcdefg") > 0);
 324         assertTrue(composed.compare("abcdef", "abcdef") == 0);
 325         assertTrue(composed.compare("abcdef", "ghijkl") < 0);
 326         assertTrue(composed.compare("ghijkl", "abcdefg") > 0);
 327     }
 328 
 329     public void testNulls() {
 330         try {
 331             Comparator.<String>naturalOrder().compare("abc", (String) null);
 332             fail("expected NPE with naturalOrder");
 333         } catch (NullPointerException npe) {}
 334         try {
 335             Comparator.<String>naturalOrder().compare((String) null, "abc");
 336             fail("expected NPE with naturalOrder");
 337         } catch (NullPointerException npe) {}
 338 
 339         try {
 340             Comparator.<String>reverseOrder().compare("abc", (String) null);
 341             fail("expected NPE with naturalOrder");
 342         } catch (NullPointerException npe) {}
 343         try {
 344             Comparator.<String>reverseOrder().compare((String) null, "abc");
 345             fail("expected NPE with naturalOrder");
 346         } catch (NullPointerException npe) {}
 347 
 348         try {
 349             Comparator<People> cmp = Comparator.comparing(null, Comparator.<String>naturalOrder());
 350             fail("comparing(null, cmp) should throw NPE");
 351         } catch (NullPointerException npe) {}
 352         try {
 353             Comparator<People> cmp = Comparator.comparing(People::getFirstName, null);
 354             fail("comparing(f, null) should throw NPE");
 355         } catch (NullPointerException npe) {}
 356 
 357         try {
 358             Comparator<People> cmp = Comparator.comparing(null);
 359             fail("comparing(null) should throw NPE");
 360         } catch (NullPointerException npe) {}
 361         try {
 362             Comparator<People> cmp = Comparator.comparingInt(null);
 363             fail("comparing(null) should throw NPE");
 364         } catch (NullPointerException npe) {}
 365         try {
 366             Comparator<People> cmp = Comparator.comparingLong(null);
 367             fail("comparing(null) should throw NPE");
 368         } catch (NullPointerException npe) {}
 369         try {
 370             Comparator<People> cmp = Comparator.comparingDouble(null);
 371             fail("comparing(null) should throw NPE");
 372         } catch (NullPointerException npe) {}
 373     }
 374 
 375     @Test(dataProvider = "presorted")
 376     public void testAlphaDecimal(String[] sorted, Comparator<String> cmp) {
 377         for (int i = 0; i < sorted.length; ++i) {
 378             for (int j = 0; j < sorted.length; ++j) {
 379                 int res = cmp.compare(sorted[i], sorted[j]);
 380                 boolean ok = (res == 0 && i == j) ||
 381                         (res <= 0 && i < j) ||
 382                         (res >= 0 && i > j);
 383                 assertTrue(ok);
 384                 if (res == 0 && i != j) {
 385                     res = cmp.compare(sorted[j], sorted[i]);
 386                     assertTrue(res == 0);
 387                 }
 388             }
 389         }
 390     }
 391 
 392     // Simple case: sorting 1 .. 11
 393     private static String[] arr0 = new String[] {
 394             "java 1", "java 2", "java 3",
 395             "java 4", "java 5", "java 6",
 396             "java 7", "java 8", "java 9",
 397             "java 10", "java 11", "java 11" };
 398 
 399     // Leading zeros and multiple numeric parts
 400     private static String[] arr1 = new String[] {
 401             "string", "string0", "string00",
 402             "string1", "string01", "string001",
 403             "string2", "string02", "string002",
 404             "string002.a", "string002.a0", "string002.a1",
 405             "string0002", "string0002",
 406             "string1234", "string10234",
 407             "string100234", "string100234",
 408             "string1000234", "string1000234" };
 409 
 410     // Leading zeros first
 411     private static String[] arr2 = new String[] {
 412             "string", "string00", "string0",
 413             "string001", "string01", "string1",
 414             "string0002", "string0002", "string002",
 415             "string002.a", "string002.a0", "string002.a1",
 416             "string02", "string02", "string2", "string2" };
 417 
 418     // Sample from MSDN
 419     private static String[] arr3 = new String[] {
 420             "2string", "3string", "20string",
 421             "st2ring", "st3ring", "st20ring",
 422             "string2", "string3", "string20" };
 423 
 424     // Very long numbers
 425     private static String[] arr4 = new String[] {
 426             "q_0",
 427             "q_1",
 428             "q_1_",
 429             "q_10000000000000000000000000000000000000000",
 430             "q_10000000000000000000000000000000000000000",
 431             "q_20000000000000000000000000000000000000000",
 432             "q_100000000000000000000000000000000000000000",
 433             "q_500000000000000000000000000000000000000000",
 434             "q_10000000000000000000000000000000000000000000000000000000000000000000000000001",
 435             "q_10000000000000000000000000000000000000000000000000000000000000000000000000001",
 436             "q_20000000000000000000000000000000000000000000000000000000000000000000000000000",
 437             "q_20000000000000000000000000000000000000000000000000000000000000000000000000001",
 438             "q_200000000000000000000000000000000000000000000000000000000000000000000000000000",
 439             "y_1",
 440             "y_10000000000000000000000000000000000000000000000000000000000000000000000000000" };
 441 
 442     // Plain numbers
 443     private static String[] arr5 = new String[] {
 444             "",
 445             "",
 446             "0",
 447             "1",
 448             "2",
 449             "10",
 450             "10",
 451             "11",
 452             "15",
 453             "19",
 454             "20",
 455             "90",
 456             "100",
 457             "101",
 458             "1024",
 459             "2042",
 460             "2147483647",
 461             "2147483648", // Integer.MAX_VALUE
 462             "2147483649",
 463             "4294967296",
 464             "9223372036854775806",
 465             "9223372036854775807", // Long.MAX_VALUE
 466             "9223372036854775808",
 467             "18446744073709551615",
 468             "18446744073709551616",
 469             "8000000000000000000000000000000000000000000",
 470             "10000000000000000000000000000000000000000500",
 471             "10000000000000000000000000000000000000000500",
 472             "10000000000000000000000000000000000000000501",
 473             "20000000000000000000000000000000000000000500",
 474             "20000000000000000000700000000000000000000000",
 475     };
 476 
 477     // Plain alphabetical strings
 478     private static String[] arr6 = new String[] {
 479             "",
 480             "a",
 481             "a",
 482             "abcd",
 483             "abcdefgh",
 484             "b",
 485             "bcd",
 486             "bcdefgh",
 487             "z",
 488             "z ",
 489             "zabcd",
 490             "zbcd",
 491             "zcd",
 492             "zz",
 493     };
 494 
 495     // Case insensitive
 496     private static String[] arr7 = new String[] {
 497             "",
 498             "5",
 499             "42",
 500             "309",
 501             "a",
 502             "A",
 503             "a 1",
 504             "A 2",
 505             "a 15",
 506             "A 21",
 507             "case 42 Insensitive",
 508             "CaSe 42 inSEnsItiVe",
 509             "CAsE 42 INSENSitive",
 510             "caSe 42 INSENSITIVE",
 511             "caSe 42 INSENSITIVE",
 512     };
 513 
 514     private static String[] replaceDigits(String[] arr, int zeroCp) {
 515         return Arrays.asList(arr)
 516                 .stream()
 517                 .map(str -> {
 518                             StringBuilder sb = new StringBuilder();
 519                             int len = Character.codePointCount(str, 0, str.length());
 520                             for (int i = 0; i < len; ) {
 521                                 int cp = str.codePointAt(i);
 522                                 i += Character.charCount(cp);
 523                                 if (Character.isDigit(cp))
 524                                     cp = zeroCp + Character.digit(cp, 10);
 525                                 sb.appendCodePoint(cp);
 526                             }
 527                             return sb.toString();
 528                         }
 529                 ).toArray(String[]::new);
 530     }
 531 
 532     @DataProvider(name = "presorted")
 533     public Object[][] createPresortedArrays() {
 534         String[][] rev = {
 535             arr0.clone(), arr1.clone(), arr2.clone(), arr3.clone(),
 536             arr4.clone(), arr5.clone(), arr6.clone(), arr7.clone(),
 537         };
 538         for (String[] r : rev) {
 539             Collections.reverse(Arrays.asList(r));
 540         }
 541         Comparator<CharSequence> naturalOrder = Comparator.comparing(
 542                 CharSequence::toString, Comparator.naturalOrder());
 543         Comparator<CharSequence> caseInsOrder = Comparator.comparing(
 544                 CharSequence::toString, String::compareToIgnoreCase);
 545         int[] digitRangeStart = {
 546                 0x0030, // Latin1
 547                 0x0660, // Arabic-Indic
 548                 0x06f0, // Extended Arabic-Indic
 549                 0x0b66, // Oriya
 550                 0x0e50, // Thai
 551                 0xa9d0, // Javanese
 552                 0xff10, // Fullwidth
 553                 0x104a0, // Osmanya
 554                 0x118e0, // Warang
 555                 0x1d7ce, // Mathematical bold
 556                 0x1d7d8, // Mathematical double-struck
 557                 0x1d7e2, // Mathematical Sans-serif
 558                 0x1d7ec, // Mathematical Sans-serif bold
 559                 0x1d7f6, // Mathematical Monospace
 560         };
 561         List<Object[]> res = new ArrayList<>();
 562         for (int i = 0; i < digitRangeStart.length; ++i) {
 563             res.add(new Object[] {replaceDigits(arr0, digitRangeStart[i]), Comparator.comparingAlphaDecimal(naturalOrder)});
 564             res.add(new Object[] {replaceDigits(arr0, digitRangeStart[i]), Comparator.comparingAlphaDecimal(naturalOrder).reversed().reversed()});
 565             res.add(new Object[] {replaceDigits(arr0, digitRangeStart[i]), Comparator.comparingAlphaDecimalLeadingZeroesFirst(naturalOrder)});
 566             res.add(new Object[] {replaceDigits(arr0, digitRangeStart[i]), Comparator.comparingAlphaDecimalLeadingZeroesFirst(naturalOrder).reversed().reversed()});
 567             res.add(new Object[] {replaceDigits(arr1, digitRangeStart[i]), Comparator.comparingAlphaDecimal(naturalOrder)});
 568             res.add(new Object[] {replaceDigits(arr1, digitRangeStart[i]), Comparator.comparingAlphaDecimal(naturalOrder).reversed().reversed().reversed().reversed()});
 569             res.add(new Object[] {replaceDigits(arr2, digitRangeStart[i]), Comparator.comparingAlphaDecimalLeadingZeroesFirst(naturalOrder)});
 570             res.add(new Object[] {replaceDigits(arr2, digitRangeStart[i]), Comparator.comparingAlphaDecimalLeadingZeroesFirst(naturalOrder).reversed().reversed().reversed().reversed()});
 571             res.add(new Object[] {replaceDigits(arr3, digitRangeStart[i]), Comparator.comparingAlphaDecimal(naturalOrder)});
 572             res.add(new Object[] {replaceDigits(arr3, digitRangeStart[i]), Comparator.comparingAlphaDecimalLeadingZeroesFirst(naturalOrder)});
 573             res.add(new Object[] {replaceDigits(arr4, digitRangeStart[i]), Comparator.comparingAlphaDecimal(naturalOrder)});
 574             res.add(new Object[] {replaceDigits(arr4, digitRangeStart[i]), Comparator.comparingAlphaDecimalLeadingZeroesFirst(naturalOrder)});
 575             res.add(new Object[] {replaceDigits(arr5, digitRangeStart[i]), Comparator.comparingAlphaDecimal(naturalOrder)});
 576             res.add(new Object[] {replaceDigits(arr5, digitRangeStart[i]), Comparator.comparingAlphaDecimal(naturalOrder).reversed().reversed()});
 577             res.add(new Object[] {replaceDigits(arr5, digitRangeStart[i]), Comparator.comparingAlphaDecimalLeadingZeroesFirst(naturalOrder)});
 578             res.add(new Object[] {replaceDigits(arr5, digitRangeStart[i]), Comparator.comparingAlphaDecimalLeadingZeroesFirst(naturalOrder).reversed().reversed()});
 579             res.add(new Object[] {replaceDigits(arr6, digitRangeStart[i]), Comparator.comparingAlphaDecimal(naturalOrder)});
 580             res.add(new Object[] {replaceDigits(arr6, digitRangeStart[i]), Comparator.comparingAlphaDecimalLeadingZeroesFirst(naturalOrder)});
 581             res.add(new Object[] {replaceDigits(arr7, digitRangeStart[i]), Comparator.comparingAlphaDecimal(caseInsOrder)});
 582             res.add(new Object[] {replaceDigits(arr7, digitRangeStart[i]), Comparator.comparingAlphaDecimalLeadingZeroesFirst(caseInsOrder)});
 583             res.add(new Object[] {replaceDigits(rev[0], digitRangeStart[i]), Comparator.comparingAlphaDecimal(naturalOrder).reversed()});
 584             res.add(new Object[] {replaceDigits(rev[0], digitRangeStart[i]), Comparator.comparingAlphaDecimal(naturalOrder).reversed().reversed().reversed()});
 585             res.add(new Object[] {replaceDigits(rev[0], digitRangeStart[i]), Comparator.comparingAlphaDecimalLeadingZeroesFirst(naturalOrder).reversed()});
 586             res.add(new Object[] {replaceDigits(rev[0], digitRangeStart[i]), Comparator.comparingAlphaDecimalLeadingZeroesFirst(naturalOrder).reversed().reversed().reversed()});
 587             res.add(new Object[] {replaceDigits(rev[1], digitRangeStart[i]), Comparator.comparingAlphaDecimal(naturalOrder).reversed()});
 588             res.add(new Object[] {replaceDigits(rev[2], digitRangeStart[i]), Comparator.comparingAlphaDecimalLeadingZeroesFirst(naturalOrder).reversed()});
 589             res.add(new Object[] {replaceDigits(rev[3], digitRangeStart[i]), Comparator.comparingAlphaDecimal(naturalOrder).reversed()});
 590             res.add(new Object[] {replaceDigits(rev[3], digitRangeStart[i]), Comparator.comparingAlphaDecimal(naturalOrder).reversed().reversed().reversed().reversed().reversed()});
 591             res.add(new Object[] {replaceDigits(rev[3], digitRangeStart[i]), Comparator.comparingAlphaDecimalLeadingZeroesFirst(naturalOrder).reversed()});
 592             res.add(new Object[] {replaceDigits(rev[3], digitRangeStart[i]), Comparator.comparingAlphaDecimalLeadingZeroesFirst(naturalOrder).reversed().reversed().reversed().reversed().reversed()});
 593             res.add(new Object[] {replaceDigits(rev[4], digitRangeStart[i]), Comparator.comparingAlphaDecimal(naturalOrder).reversed()});
 594             res.add(new Object[] {replaceDigits(rev[4], digitRangeStart[i]), Comparator.comparingAlphaDecimalLeadingZeroesFirst(naturalOrder).reversed()});
 595             res.add(new Object[] {replaceDigits(rev[5], digitRangeStart[i]), Comparator.comparingAlphaDecimal(naturalOrder).reversed()});
 596             res.add(new Object[] {replaceDigits(rev[5], digitRangeStart[i]), Comparator.comparingAlphaDecimalLeadingZeroesFirst(naturalOrder).reversed()});
 597             res.add(new Object[] {replaceDigits(rev[6], digitRangeStart[i]), Comparator.comparingAlphaDecimal(naturalOrder).reversed()});
 598             res.add(new Object[] {replaceDigits(rev[6], digitRangeStart[i]), Comparator.comparingAlphaDecimalLeadingZeroesFirst(naturalOrder).reversed()});
 599             res.add(new Object[] {replaceDigits(rev[7], digitRangeStart[i]), Comparator.comparingAlphaDecimal(caseInsOrder).reversed()});
 600             res.add(new Object[] {replaceDigits(rev[7], digitRangeStart[i]), Comparator.comparingAlphaDecimal(caseInsOrder).reversed().reversed().reversed()});
 601             res.add(new Object[] {replaceDigits(rev[7], digitRangeStart[i]), Comparator.comparingAlphaDecimalLeadingZeroesFirst(caseInsOrder).reversed()});
 602         }
 603         return res.toArray(new Object[res.size()][]);
 604     }
 605 }