4343public class U <T > {
4444 private static final Map <String , Function <String , String >> FUNCTIONS = newLinkedHashMap ();
4545 private static final Map <String , String > TEMPLATE_SETTINGS = new HashMap <String , String >();
46- private static final int ARRAY_SIZE_2 = 2 ;
4746 private static final int MIN_PASSWORD_LENGTH_8 = 8 ;
4847 private static final long CAPACITY_SIZE_5 = 5L ;
4948 private static final long CAPACITY_COEFF_2 = 2L ;
@@ -57,7 +56,7 @@ public class U<T> {
5756 private static final String S_Q = "\\ s*\\ Q" ;
5857 private static final String E_S = "\\ E\\ s*" ;
5958 private static final java .util .regex .Pattern FORMAT_PATTERN =
60- java .util .regex .Pattern .compile ("\\ {\\ s*(\\ d*)\\ s*\\ }" );
59+ java .util .regex .Pattern .compile ("\\ {\\ s*(\\ d*)\\ s*}" );
6160 private static final Map <Character , String > ESCAPES = new HashMap <Character , String >();
6261 private final Iterable <T > iterable ;
6362 private final Optional <String > string ;
@@ -721,10 +720,10 @@ public Class<?> apply(Object input) {
721720 });
722721 try {
723722 final Method method = iterable .iterator ().next ().getClass ().getMethod (methodName , argTypes .toArray (
724- new Class [argTypes . size () ]));
723+ new Class [0 ]));
725724 for (E arg : iterable ) {
726725 try {
727- result .add ((E ) method .invoke (arg , args .toArray (new Object [args . size () ])));
726+ result .add ((E ) method .invoke (arg , args .toArray (new Object [0 ])));
728727 } catch (Exception e ) {
729728 throw new IllegalArgumentException (e );
730729 }
@@ -920,8 +919,8 @@ public static <T extends Comparable<? super T>> List<T> sortWith(final Iterable<
920919 }
921920
922921 @ SuppressWarnings ("unchecked" )
923- public <T extends Comparable <? super T >> List <T > sortWith (final Comparator <T > comparator ) {
924- return sortWith ((Iterable <T >) iterable , comparator );
922+ public <E extends Comparable <? super E >> List <E > sortWith (final Comparator <E > comparator ) {
923+ return sortWith ((Iterable <E >) iterable , comparator );
925924 }
926925
927926 /*
@@ -1131,7 +1130,7 @@ public static <E> List<List<E>> partition(final Iterable<E> iterable, final Pred
11311130
11321131 @ SuppressWarnings ("unchecked" )
11331132 public static <E > List <E >[] partition (final E [] iterable , final Predicate <E > pred ) {
1134- return ( List < E >[]) partition (Arrays .asList (iterable ), pred ).toArray (new ArrayList [ARRAY_SIZE_2 ]);
1133+ return partition (Arrays .asList (iterable ), pred ).toArray (new ArrayList [0 ]);
11351134 }
11361135
11371136 public T singleOrNull () {
@@ -1568,8 +1567,8 @@ public static <E> List<E> intersection(final List<E> list1, final List<E> list2)
15681567 public static <E > List <E > intersection (final List <E > list , final List <E > ... lists ) {
15691568 final Deque <List <E >> stack = new ArrayDeque <List <E >>();
15701569 stack .push (list );
1571- for (int index = 0 ; index < lists . length ; index += 1 ) {
1572- stack .push (intersection (stack .peek (), lists [ index ] ));
1570+ for (List < E > es : lists ) {
1571+ stack .push (intersection (stack .peek (), es ));
15731572 }
15741573 return stack .peek ();
15751574 }
@@ -1606,8 +1605,8 @@ public static <E> List<E> difference(final List<E> list1, final List<E> list2) {
16061605 public static <E > List <E > difference (final List <E > list , final List <E > ... lists ) {
16071606 final Deque <List <E >> stack = new ArrayDeque <List <E >>();
16081607 stack .push (list );
1609- for (int index = 0 ; index < lists . length ; index += 1 ) {
1610- stack .push (difference (stack .peek (), lists [ index ] ));
1608+ for (List < E > es : lists ) {
1609+ stack .push (difference (stack .peek (), es ));
16111610 }
16121611 return stack .peek ();
16131612 }
@@ -1655,8 +1654,8 @@ public static <T> List<List<T>> unzip(final List<T> ... lists) {
16551654 final List <List <T >> unzipped = newArrayList ();
16561655 for (int index = 0 ; index < lists [0 ].size (); index += 1 ) {
16571656 final List <T > nTuple = newArrayList ();
1658- for (int index2 = 0 ; index2 < lists . length ; index2 += 1 ) {
1659- nTuple .add (lists [ index2 ] .get (index ));
1657+ for (List < T > list : lists ) {
1658+ nTuple .add (list .get (index ));
16601659 }
16611660 unzipped .add (nTuple );
16621661 }
@@ -1866,7 +1865,7 @@ public static <T> List<List<T>> chunk(final Iterable<T> iterable, final int size
18661865 }
18671866 int index = 0 ;
18681867 int length = size (iterable );
1869- final List <List <T >> result = new ArrayList <List <T >>(size == 0 ? size : (( length / size ) + 1 ) );
1868+ final List <List <T >> result = new ArrayList <List <T >>(size == 0 ? size : (length / size ) + 1 );
18701869 while (index < length ) {
18711870 result .add (newArrayList (iterable ).subList (index , Math .min (length , index + size )));
18721871 index += step ;
@@ -2264,9 +2263,9 @@ public static <K, V> Map<K, V> extend(final Map<K, V> destination, final Map<K,
22642263 }
22652264
22662265 public static <E > E findKey (final List <E > list , final Predicate <E > pred ) {
2267- for (int index = 0 ; index < list . size (); index ++ ) {
2268- if (pred .test (list . get ( index ) )) {
2269- return list . get ( index ) ;
2266+ for (E e : list ) {
2267+ if (pred .test (e )) {
2268+ return e ;
22702269 }
22712270 }
22722271 return null ;
@@ -3127,7 +3126,7 @@ public Optional<String> call(final String funcName) {
31273126
31283127 public static <T extends Comparable <T >> List <T > sort (final Iterable <T > iterable ) {
31293128 final List <T > localList = newArrayList (iterable );
3130- Collections .< T > sort (localList );
3129+ Collections .sort (localList );
31313130 return localList ;
31323131 }
31333132
0 commit comments