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
|
@ -196,10 +196,9 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
|||
* @throws NullPointerException if the specified collection is null
|
||||
*/
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
if (!(c instanceof RegularEnumSet))
|
||||
if (!(c instanceof RegularEnumSet<?> es))
|
||||
return super.containsAll(c);
|
||||
|
||||
RegularEnumSet<?> es = (RegularEnumSet<?>)c;
|
||||
if (es.elementType != elementType)
|
||||
return es.isEmpty();
|
||||
|
||||
|
@ -215,10 +214,9 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
|||
* of its elements are null
|
||||
*/
|
||||
public boolean addAll(Collection<? extends E> c) {
|
||||
if (!(c instanceof RegularEnumSet))
|
||||
if (!(c instanceof RegularEnumSet<?> es))
|
||||
return super.addAll(c);
|
||||
|
||||
RegularEnumSet<?> es = (RegularEnumSet<?>)c;
|
||||
if (es.elementType != elementType) {
|
||||
if (es.isEmpty())
|
||||
return false;
|
||||
|
@ -241,10 +239,9 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
|||
* @throws NullPointerException if the specified collection is null
|
||||
*/
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
if (!(c instanceof RegularEnumSet))
|
||||
if (!(c instanceof RegularEnumSet<?> es))
|
||||
return super.removeAll(c);
|
||||
|
||||
RegularEnumSet<?> es = (RegularEnumSet<?>)c;
|
||||
if (es.elementType != elementType)
|
||||
return false;
|
||||
|
||||
|
@ -262,10 +259,9 @@ class RegularEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
|||
* @throws NullPointerException if the specified collection is null
|
||||
*/
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
if (!(c instanceof RegularEnumSet))
|
||||
if (!(c instanceof RegularEnumSet<?> es))
|
||||
return super.retainAll(c);
|
||||
|
||||
RegularEnumSet<?> es = (RegularEnumSet<?>)c;
|
||||
if (es.elementType != elementType) {
|
||||
boolean changed = (elements != 0);
|
||||
elements = 0;
|
||||
|
@ -294,10 +290,9 @@ class RegularEnumSet<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 RegularEnumSet))
|
||||
if (!(o instanceof RegularEnumSet<?> es))
|
||||
return super.equals(o);
|
||||
|
||||
RegularEnumSet<?> es = (RegularEnumSet<?>)o;
|
||||
if (es.elementType != elementType)
|
||||
return elements == 0 && es.elements == 0;
|
||||
return es.elements == elements;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue