mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8267110: Update java.util to use instanceof pattern variable
Reviewed-by: lancea, naoto
This commit is contained in:
parent
0a03fc84b3
commit
a52c4ede2f
29 changed files with 142 additions and 266 deletions
|
@ -248,10 +248,9 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
|||
* @throws NullPointerException if the specified collection is null
|
||||
*/
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
if (!(c instanceof JumboEnumSet))
|
||||
if (!(c instanceof JumboEnumSet<?> es))
|
||||
return super.containsAll(c);
|
||||
|
||||
JumboEnumSet<?> es = (JumboEnumSet<?>)c;
|
||||
if (es.elementType != elementType)
|
||||
return es.isEmpty();
|
||||
|
||||
|
@ -270,10 +269,9 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
|||
* its elements are null
|
||||
*/
|
||||
public boolean addAll(Collection<? extends E> c) {
|
||||
if (!(c instanceof JumboEnumSet))
|
||||
if (!(c instanceof JumboEnumSet<?> es))
|
||||
return super.addAll(c);
|
||||
|
||||
JumboEnumSet<?> es = (JumboEnumSet<?>)c;
|
||||
if (es.elementType != elementType) {
|
||||
if (es.isEmpty())
|
||||
return false;
|
||||
|
@ -296,10 +294,9 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
|||
* @throws NullPointerException if the specified collection is null
|
||||
*/
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
if (!(c instanceof JumboEnumSet))
|
||||
if (!(c instanceof JumboEnumSet<?> es))
|
||||
return super.removeAll(c);
|
||||
|
||||
JumboEnumSet<?> es = (JumboEnumSet<?>)c;
|
||||
if (es.elementType != elementType)
|
||||
return false;
|
||||
|
||||
|
@ -317,10 +314,9 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
|||
* @throws NullPointerException if the specified collection is null
|
||||
*/
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
if (!(c instanceof JumboEnumSet))
|
||||
if (!(c instanceof JumboEnumSet<?> es))
|
||||
return super.retainAll(c);
|
||||
|
||||
JumboEnumSet<?> es = (JumboEnumSet<?>)c;
|
||||
if (es.elementType != elementType) {
|
||||
boolean changed = (size != 0);
|
||||
clear();
|
||||
|
@ -350,10 +346,9 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
|||
* @return {@code true} if the specified object is equal to this set
|
||||
*/
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof JumboEnumSet))
|
||||
if (!(o instanceof JumboEnumSet<?> es))
|
||||
return super.equals(o);
|
||||
|
||||
JumboEnumSet<?> es = (JumboEnumSet<?>)o;
|
||||
if (es.elementType != elementType)
|
||||
return size == 0 && es.size == 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue