Rabbit-R1/switch port/java/sources/com/google/common/collect/SingletonImmutableSet.java
2024-05-21 17:08:36 -04:00

60 lines
2.3 KiB
Java

package com.google.common.collect;
import com.google.common.base.Preconditions;
import javax.annotation.CheckForNull;
/* JADX INFO: Access modifiers changed from: package-private */
@ElementTypesAreNonnullByDefault
/* loaded from: classes3.dex */
public final class SingletonImmutableSet<E> extends ImmutableSet<E> {
final transient E element;
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.ImmutableCollection
public boolean isPartialView() {
return false;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public int size() {
return 1;
}
/* JADX INFO: Access modifiers changed from: package-private */
public SingletonImmutableSet(E e) {
this.element = (E) Preconditions.checkNotNull(e);
}
@Override // com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean contains(@CheckForNull Object obj) {
return this.element.equals(obj);
}
@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 UnmodifiableIterator<E> iterator() {
return Iterators.singletonIterator(this.element);
}
@Override // com.google.common.collect.ImmutableSet, com.google.common.collect.ImmutableCollection
public ImmutableList<E> asList() {
return ImmutableList.of((Object) this.element);
}
/* JADX INFO: Access modifiers changed from: package-private */
@Override // com.google.common.collect.ImmutableCollection
public int copyIntoArray(Object[] objArr, int i) {
objArr[i] = this.element;
return i + 1;
}
@Override // com.google.common.collect.ImmutableSet, java.util.Collection, java.util.Set
public final int hashCode() {
return this.element.hashCode();
}
@Override // java.util.AbstractCollection
public String toString() {
String obj = this.element.toString();
return new StringBuilder(String.valueOf(obj).length() + 2).append('[').append(obj).append(']').toString();
}
}