@@ -141,7 +141,6 @@ private Collections() {
141
141
* found to violate the {@link Comparable} contract
142
142
* @see List#sort(Comparator)
143
143
*/
144
- @ SuppressWarnings ("unchecked" )
145
144
public static <T extends Comparable <? super T >> void sort (List <T > list ) {
146
145
list .sort (null );
147
146
}
@@ -175,7 +174,6 @@ public static <T extends Comparable<? super T>> void sort(List<T> list) {
175
174
* found to violate the {@link Comparator} contract
176
175
* @see List#sort(Comparator)
177
176
*/
178
- @ SuppressWarnings ({"unchecked" , "rawtypes" })
179
177
public static <T > void sort (List <T > list , Comparator <? super T > c ) {
180
178
list .sort (c );
181
179
}
@@ -267,7 +265,7 @@ else if (cmp > 0)
267
265
* list listIterator.
268
266
*/
269
267
private static <T > T get (ListIterator <? extends T > i , int index ) {
270
- T obj = null ;
268
+ T obj ;
271
269
int pos = i .nextIndex ();
272
270
if (pos <= index ) {
273
271
do {
@@ -651,10 +649,10 @@ public static <T extends Object & Comparable<? super T>> T min(Collection<? exte
651
649
* @throws NoSuchElementException if the collection is empty.
652
650
* @see Comparable
653
651
*/
654
- @ SuppressWarnings ({"unchecked" , "rawtypes" })
652
+ @ SuppressWarnings ({"unchecked" })
655
653
public static <T > T min (Collection <? extends T > coll , Comparator <? super T > comp ) {
656
654
if (comp ==null )
657
- return (T )min ((Collection ) coll );
655
+ return (T )min ((Collection < Comparable < Object >> ) coll );
658
656
659
657
Iterator <? extends T > i = coll .iterator ();
660
658
T candidate = i .next ();
@@ -724,10 +722,10 @@ public static <T extends Object & Comparable<? super T>> T max(Collection<? exte
724
722
* @throws NoSuchElementException if the collection is empty.
725
723
* @see Comparable
726
724
*/
727
- @ SuppressWarnings ({"unchecked" , "rawtypes" })
725
+ @ SuppressWarnings ({"unchecked" })
728
726
public static <T > T max (Collection <? extends T > coll , Comparator <? super T > comp ) {
729
727
if (comp ==null )
730
- return (T )max ((Collection ) coll );
728
+ return (T )max ((Collection < Comparable < Object >> ) coll );
731
729
732
730
Iterator <? extends T > i = coll .iterator ();
733
731
T candidate = i .next ();
@@ -1067,7 +1065,7 @@ static class UnmodifiableCollection<E> implements Collection<E>, Serializable {
1067
1065
public String toString () {return c .toString ();}
1068
1066
1069
1067
public Iterator <E > iterator () {
1070
- return new Iterator <E >() {
1068
+ return new Iterator <>() {
1071
1069
private final Iterator <? extends E > i = c .iterator ();
1072
1070
1073
1071
public boolean hasNext () {return i .hasNext ();}
@@ -1279,7 +1277,6 @@ public EmptyNavigableSet() {
1279
1277
private Object readResolve () { return EMPTY_NAVIGABLE_SET ; }
1280
1278
}
1281
1279
1282
- @ SuppressWarnings ("rawtypes" )
1283
1280
private static final NavigableSet <?> EMPTY_NAVIGABLE_SET =
1284
1281
new EmptyNavigableSet <>();
1285
1282
@@ -1392,7 +1389,7 @@ public void sort(Comparator<? super E> c) {
1392
1389
public ListIterator <E > listIterator () {return listIterator (0 );}
1393
1390
1394
1391
public ListIterator <E > listIterator (final int index ) {
1395
- return new ListIterator <E >() {
1392
+ return new ListIterator <>() {
1396
1393
private final ListIterator <? extends E > i
1397
1394
= list .listIterator (index );
1398
1395
@@ -1634,10 +1631,9 @@ static class UnmodifiableEntrySet<K,V>
1634
1631
@ java .io .Serial
1635
1632
private static final long serialVersionUID = 7854390611657943733L ;
1636
1633
1637
- @ SuppressWarnings ({"unchecked" , "rawtypes" })
1634
+ @ SuppressWarnings ({"unchecked" })
1638
1635
UnmodifiableEntrySet (Set <? extends Map .Entry <? extends K , ? extends V >> s ) {
1639
- // Need to cast to raw in order to work around a limitation in the type system
1640
- super ((Set )s );
1636
+ super ((Set <Map .Entry <K , V >>)s );
1641
1637
}
1642
1638
1643
1639
static <K , V > Consumer <Map .Entry <? extends K , ? extends V >> entryConsumer (
@@ -1721,7 +1717,7 @@ public Stream<Entry<K,V>> parallelStream() {
1721
1717
}
1722
1718
1723
1719
public Iterator <Map .Entry <K ,V >> iterator () {
1724
- return new Iterator <Map . Entry < K , V > >() {
1720
+ return new Iterator <>() {
1725
1721
private final Iterator <? extends Map .Entry <? extends K , ? extends V >> i = c .iterator ();
1726
1722
1727
1723
public boolean hasNext () {
@@ -1920,7 +1916,7 @@ static class UnmodifiableNavigableMap<K,V>
1920
1916
private static final long serialVersionUID = -4858195264774772197L ;
1921
1917
1922
1918
/**
1923
- * A class for the {@link EMPTY_NAVIGABLE_MAP} which needs readResolve
1919
+ * A class for the {@link # EMPTY_NAVIGABLE_MAP} which needs readResolve
1924
1920
* to preserve singleton property.
1925
1921
*
1926
1922
* @param <K> type of keys, if there were any, and of bounds
@@ -1943,7 +1939,7 @@ public NavigableSet<K> navigableKeySet()
1943
1939
}
1944
1940
1945
1941
/**
1946
- * Singleton for {@link emptyNavigableMap()} which is also immutable.
1942
+ * Singleton for {@link # emptyNavigableMap()} which is also immutable.
1947
1943
*/
1948
1944
private static final EmptyNavigableMap <?,?> EMPTY_NAVIGABLE_MAP =
1949
1945
new EmptyNavigableMap <>();
@@ -3191,7 +3187,7 @@ public Iterator<E> iterator() {
3191
3187
// JDK-6363904 - unwrapped iterator could be typecast to
3192
3188
// ListIterator with unsafe set()
3193
3189
final Iterator <E > it = c .iterator ();
3194
- return new Iterator <E >() {
3190
+ return new Iterator <>() {
3195
3191
public boolean hasNext () { return it .hasNext (); }
3196
3192
public E next () { return it .next (); }
3197
3193
public void remove () { it .remove (); }
@@ -3582,7 +3578,7 @@ public boolean addAll(int index, Collection<? extends E> c) {
3582
3578
public ListIterator <E > listIterator (final int index ) {
3583
3579
final ListIterator <E > i = list .listIterator (index );
3584
3580
3585
- return new ListIterator <E >() {
3581
+ return new ListIterator <>() {
3586
3582
public boolean hasNext () { return i .hasNext (); }
3587
3583
public E next () { return i .next (); }
3588
3584
public boolean hasPrevious () { return i .hasPrevious (); }
@@ -3890,7 +3886,7 @@ public boolean addAll(Collection<? extends Map.Entry<K, V>> coll) {
3890
3886
public Iterator <Map .Entry <K ,V >> iterator () {
3891
3887
final Iterator <Map .Entry <K , V >> i = s .iterator ();
3892
3888
3893
- return new Iterator <Map . Entry < K , V > >() {
3889
+ return new Iterator <>() {
3894
3890
public boolean hasNext () { return i .hasNext (); }
3895
3891
public void remove () { i .remove (); }
3896
3892
@@ -4745,7 +4741,6 @@ public boolean equals(Object o) {
4745
4741
4746
4742
// Override default methods in Map
4747
4743
@ Override
4748
- @ SuppressWarnings ("unchecked" )
4749
4744
public V getOrDefault (Object k , V defaultValue ) {
4750
4745
return defaultValue ;
4751
4746
}
@@ -4826,7 +4821,7 @@ public static <T> Set<T> singleton(T o) {
4826
4821
}
4827
4822
4828
4823
static <E > Iterator <E > singletonIterator (final E e ) {
4829
- return new Iterator <E >() {
4824
+ return new Iterator <>() {
4830
4825
private boolean hasNext = true ;
4831
4826
public boolean hasNext () {
4832
4827
return hasNext ;
@@ -4859,7 +4854,7 @@ public void forEachRemaining(Consumer<? super E> action) {
4859
4854
* @return A singleton {@code Spliterator}
4860
4855
*/
4861
4856
static <T > Spliterator <T > singletonSpliterator (final T element ) {
4862
- return new Spliterator <T >() {
4857
+ return new Spliterator <>() {
4863
4858
long est = 1 ;
4864
4859
4865
4860
@ Override
@@ -5061,7 +5056,7 @@ public Set<K> keySet() {
5061
5056
5062
5057
public Set <Map .Entry <K ,V >> entrySet () {
5063
5058
if (entrySet ==null )
5064
- entrySet = Collections .< Map . Entry < K , V >> singleton (
5059
+ entrySet = Collections .singleton (
5065
5060
new SimpleImmutableEntry <>(k , v ));
5066
5061
return entrySet ;
5067
5062
}
@@ -5429,8 +5424,8 @@ public int compare(T t1, T t2) {
5429
5424
5430
5425
public boolean equals (Object o ) {
5431
5426
return (o == this ) ||
5432
- (o instanceof ReverseComparator2 &&
5433
- cmp .equals ((( ReverseComparator2 ) o ) .cmp ));
5427
+ (o instanceof ReverseComparator2 <?> that &&
5428
+ cmp .equals (that .cmp ));
5434
5429
}
5435
5430
5436
5431
public int hashCode () {
@@ -5459,7 +5454,7 @@ public Comparator<T> reversed() {
5459
5454
* @see Enumeration
5460
5455
*/
5461
5456
public static <T > Enumeration <T > enumeration (final Collection <T > c ) {
5462
- return new Enumeration <T >() {
5457
+ return new Enumeration <>() {
5463
5458
private final Iterator <T > i = c .iterator ();
5464
5459
5465
5460
public boolean hasMoreElements () {
0 commit comments