88 lines
3.2 KiB
Java
88 lines
3.2 KiB
Java
package com.google.common.collect;
|
|
|
|
import com.google.common.base.Preconditions;
|
|
import java.util.Iterator;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public final class SingletonImmutableSet<E> extends ImmutableSet<E> {
|
|
private transient int cachedHashCode;
|
|
final transient E element;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.ImmutableCollection
|
|
public final boolean isPartialView() {
|
|
return false;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public final int size() {
|
|
return 1;
|
|
}
|
|
|
|
@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 SingletonImmutableSet(E e) {
|
|
this.element = (E) Preconditions.checkNotNull(e);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public SingletonImmutableSet(E e, int i) {
|
|
this.element = e;
|
|
this.cachedHashCode = i;
|
|
}
|
|
|
|
@Override // com.google.common.collect.ImmutableCollection, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public final boolean contains(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 final UnmodifiableIterator<E> iterator() {
|
|
return Iterators.singletonIterator(this.element);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.ImmutableSet
|
|
public final ImmutableList<E> createAsList() {
|
|
return ImmutableList.of((Object) this.element);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.ImmutableCollection
|
|
public final 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() {
|
|
int i = this.cachedHashCode;
|
|
if (i != 0) {
|
|
return i;
|
|
}
|
|
int hashCode = this.element.hashCode();
|
|
this.cachedHashCode = hashCode;
|
|
return hashCode;
|
|
}
|
|
|
|
@Override // java.util.AbstractCollection
|
|
public final String toString() {
|
|
String obj = this.element.toString();
|
|
StringBuilder sb = new StringBuilder(String.valueOf(obj).length() + 2);
|
|
sb.append('[');
|
|
sb.append(obj);
|
|
sb.append(']');
|
|
return sb.toString();
|
|
}
|
|
|
|
@Override // com.google.common.collect.ImmutableSet
|
|
final boolean isHashCodeFast() {
|
|
return this.cachedHashCode != 0;
|
|
}
|
|
}
|