4444 */
4545public class CompositeFileComparator extends AbstractFileComparator implements Serializable {
4646
47- private static final Comparator [] NO_COMPARATORS = {};
47+ private static final Comparator <?> [] NO_COMPARATORS = {};
4848 private final Comparator <File >[] delegates ;
4949
5050 /**
5151 * Create a composite comparator for the set of delegate comparators.
5252 *
5353 * @param delegates The delegate file comparators
5454 */
55+ @ SuppressWarnings ("unchecked" ) // casts 1 & 2 must be OK because types are already correct
5556 public CompositeFileComparator (Comparator <File >... delegates ) {
5657 if (delegates == null ) {
57- this .delegates = NO_COMPARATORS ;
58+ this .delegates = ( Comparator < File >[]) NO_COMPARATORS ;//1
5859 } else {
59- this .delegates = new Comparator [delegates .length ];
60+ this .delegates = ( Comparator < File >[]) new Comparator <?> [delegates .length ];//2
6061 System .arraycopy (delegates , 0 , this .delegates , 0 , delegates .length );
6162 }
6263 }
@@ -66,15 +67,16 @@ public CompositeFileComparator(Comparator<File>... delegates) {
6667 *
6768 * @param delegates The delegate file comparators
6869 */
70+ @ SuppressWarnings ("unchecked" ) // casts 1 & 2 must be OK because types are already correct
6971 public CompositeFileComparator (Iterable <Comparator <File >> delegates ) {
7072 if (delegates == null ) {
71- this .delegates = NO_COMPARATORS ;
73+ this .delegates = ( Comparator < File >[]) NO_COMPARATORS ; //1
7274 } else {
7375 List <Comparator <File >> list = new ArrayList <Comparator <File >>();
7476 for (Comparator <File > comparator : delegates ) {
7577 list .add (comparator );
7678 }
77- this .delegates = list .toArray (new Comparator [list .size ()]);
79+ this .delegates = ( Comparator < File >[]) list .toArray (new Comparator <?> [list .size ()]); //2
7880 }
7981 }
8082
0 commit comments