Rabbit-R1/switch port/java/sources/com/google/common/base/Absent.java

83 lines
2.3 KiB
Java
Raw Normal View History

2024-05-21 16:08:36 -05:00
package com.google.common.base;
import java.util.Collections;
import java.util.Set;
import javax.annotation.CheckForNull;
/* JADX INFO: Access modifiers changed from: package-private */
@ElementTypesAreNonnullByDefault
/* loaded from: classes2.dex */
public final class Absent<T> extends Optional<T> {
static final Absent<Object> INSTANCE = new Absent<>();
private static final long serialVersionUID = 0;
private Object readResolve() {
return INSTANCE;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static <T> Optional<T> withType() {
return INSTANCE;
}
@Override // com.google.common.base.Optional
public boolean equals(@CheckForNull Object obj) {
return obj == this;
}
@Override // com.google.common.base.Optional
public int hashCode() {
return 2040732332;
}
@Override // com.google.common.base.Optional
public boolean isPresent() {
return false;
}
@Override // com.google.common.base.Optional
@CheckForNull
public T orNull() {
return null;
}
@Override // com.google.common.base.Optional
public String toString() {
return "Optional.absent()";
}
private Absent() {
}
@Override // com.google.common.base.Optional
public T get() {
throw new IllegalStateException("Optional.get() cannot be called on an absent value");
}
@Override // com.google.common.base.Optional
public T or(T t) {
return (T) Preconditions.checkNotNull(t, "use Optional.orNull() instead of Optional.or(null)");
}
@Override // com.google.common.base.Optional
public Optional<T> or(Optional<? extends T> optional) {
return (Optional) Preconditions.checkNotNull(optional);
}
@Override // com.google.common.base.Optional
public T or(Supplier<? extends T> supplier) {
return (T) Preconditions.checkNotNull(supplier.get(), "use Optional.orNull() instead of a Supplier that returns null");
}
@Override // com.google.common.base.Optional
public Set<T> asSet() {
return Collections.emptySet();
}
@Override // com.google.common.base.Optional
public <V> Optional<V> transform(Function<? super T, V> function) {
Preconditions.checkNotNull(function);
return Optional.absent();
}
}