77 lines
1.9 KiB
Java
77 lines
1.9 KiB
Java
package com.google.common.base;
|
|
|
|
import java.util.Collections;
|
|
import java.util.Set;
|
|
|
|
/* loaded from: classes.dex */
|
|
final class Present<T> extends Optional<T> {
|
|
private final T a;
|
|
|
|
Present(T t) {
|
|
this.a = t;
|
|
}
|
|
|
|
@Override // com.google.common.base.Optional
|
|
public Set<T> asSet() {
|
|
return Collections.singleton(this.a);
|
|
}
|
|
|
|
@Override // com.google.common.base.Optional
|
|
public boolean equals(Object obj) {
|
|
if (obj instanceof Present) {
|
|
return this.a.equals(((Present) obj).a);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override // com.google.common.base.Optional
|
|
public T get() {
|
|
return this.a;
|
|
}
|
|
|
|
@Override // com.google.common.base.Optional
|
|
public int hashCode() {
|
|
return this.a.hashCode() + 1502476572;
|
|
}
|
|
|
|
@Override // com.google.common.base.Optional
|
|
public boolean isPresent() {
|
|
return true;
|
|
}
|
|
|
|
@Override // com.google.common.base.Optional
|
|
public T or(T t) {
|
|
Preconditions.a(t, "use Optional.orNull() instead of Optional.or(null)");
|
|
return this.a;
|
|
}
|
|
|
|
@Override // com.google.common.base.Optional
|
|
public T orNull() {
|
|
return this.a;
|
|
}
|
|
|
|
@Override // com.google.common.base.Optional
|
|
public String toString() {
|
|
return "Optional.of(" + this.a + ")";
|
|
}
|
|
|
|
@Override // com.google.common.base.Optional
|
|
public <V> Optional<V> transform(Function<? super T, V> function) {
|
|
V apply = function.apply(this.a);
|
|
Preconditions.a(apply, "the Function passed to Optional.transform() must not return null.");
|
|
return new Present(apply);
|
|
}
|
|
|
|
@Override // com.google.common.base.Optional
|
|
public Optional<T> or(Optional<? extends T> optional) {
|
|
Preconditions.a(optional);
|
|
return this;
|
|
}
|
|
|
|
@Override // com.google.common.base.Optional
|
|
public T or(Supplier<? extends T> supplier) {
|
|
Preconditions.a(supplier);
|
|
return this.a;
|
|
}
|
|
}
|