what-the-bank/sources/com/google/common/collect/ImmutableEnumSet.java

120 lines
4.2 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.common.collect;
import java.io.Serializable;
import java.lang.Enum;
import java.util.Collection;
import java.util.EnumSet;
import java.util.Iterator;
/* loaded from: classes2.dex */
final class ImmutableEnumSet<E extends Enum<E>> extends ImmutableSet<E> {
private final transient EnumSet<E> delegate;
private transient int hashCode;
@Override // com.google.common.collect.ImmutableSet
final boolean isHashCodeFast() {
return true;
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.ImmutableCollection
public final boolean isPartialView() {
return false;
}
@Override // com.google.common.collect.ImmutableSet, com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set, java.util.NavigableSet, com.google.common.collect.SortedIterable
public final /* bridge */ /* synthetic */ Iterator iterator() {
return iterator();
}
/* JADX INFO: Access modifiers changed from: package-private */
public static ImmutableSet asImmutable(EnumSet enumSet) {
int size = enumSet.size();
if (size == 0) {
return ImmutableSet.of();
}
if (size == 1) {
return ImmutableSet.of(Iterables.getOnlyElement(enumSet));
}
return new ImmutableEnumSet(enumSet);
}
private ImmutableEnumSet(EnumSet<E> enumSet) {
this.delegate = enumSet;
}
@Override // com.google.common.collect.ImmutableSet, com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set, java.util.NavigableSet, com.google.common.collect.SortedIterable
public final UnmodifiableIterator<E> iterator() {
return Iterators.unmodifiableIterator(this.delegate.iterator());
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final int size() {
return this.delegate.size();
}
@Override // com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.Set
public final boolean contains(Object obj) {
return this.delegate.contains(obj);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final boolean containsAll(Collection<?> collection) {
if (collection instanceof ImmutableEnumSet) {
collection = ((ImmutableEnumSet) collection).delegate;
}
return this.delegate.containsAll(collection);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final boolean isEmpty() {
return this.delegate.isEmpty();
}
@Override // com.google.common.collect.ImmutableSet, java.util.Collection, java.util.Set
public final boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof ImmutableEnumSet) {
obj = ((ImmutableEnumSet) obj).delegate;
}
return this.delegate.equals(obj);
}
@Override // com.google.common.collect.ImmutableSet, java.util.Collection, java.util.Set
public final int hashCode() {
int i = this.hashCode;
if (i != 0) {
return i;
}
int hashCode = this.delegate.hashCode();
this.hashCode = hashCode;
return hashCode;
}
@Override // java.util.AbstractCollection
public final String toString() {
return this.delegate.toString();
}
@Override // com.google.common.collect.ImmutableSet, com.google.common.collect.ImmutableCollection
final Object writeReplace() {
return new EnumSerializedForm(this.delegate);
}
/* loaded from: classes2.dex */
static class EnumSerializedForm<E extends Enum<E>> implements Serializable {
private static final long serialVersionUID = 0;
final EnumSet<E> delegate;
EnumSerializedForm(EnumSet<E> enumSet) {
this.delegate = enumSet;
}
Object readResolve() {
return new ImmutableEnumSet(this.delegate.clone());
}
}
}