what-the-bank/sources/com/google/common/base/Optional.java

84 lines
2.5 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.common.base;
import java.io.Serializable;
import java.util.Iterator;
import java.util.Set;
/* loaded from: classes2.dex */
public abstract class Optional<T> implements Serializable {
private static final long serialVersionUID = 0;
public abstract Set<T> asSet();
public abstract boolean equals(Object obj);
public abstract T get();
public abstract int hashCode();
public abstract boolean isPresent();
public abstract Optional<T> or(Optional<? extends T> optional);
public abstract T or(Supplier<? extends T> supplier);
public abstract T or(T t);
public abstract T orNull();
public abstract String toString();
public abstract <V> Optional<V> transform(Function<? super T, V> function);
public static <T> Optional<T> absent() {
return Absent.withType();
}
public static <T> Optional<T> of(T t) {
return new Present(Preconditions.checkNotNull(t));
}
public static <T> Optional<T> fromNullable(T t) {
return t == null ? absent() : new Present(t);
}
/* renamed from: com.google.common.base.Optional$1, reason: invalid class name */
/* loaded from: classes2.dex */
class AnonymousClass1 implements Iterable<T> {
final Iterable val$optionals;
AnonymousClass1(Iterable iterable) {
this.val$optionals = iterable;
}
@Override // java.lang.Iterable
public Iterator<T> iterator() {
return new AbstractIterator<T>(this) { // from class: com.google.common.base.Optional.1.1
private final Iterator<? extends Optional<? extends T>> iterator;
final AnonymousClass1 this$0;
{
this.this$0 = this;
this.iterator = (Iterator) Preconditions.checkNotNull(this.val$optionals.iterator());
}
@Override // com.google.common.base.AbstractIterator
protected T computeNext() {
while (this.iterator.hasNext()) {
Optional<? extends T> next = this.iterator.next();
if (next.isPresent()) {
return next.get();
}
}
return endOfData();
}
};
}
}
public static <T> Iterable<T> presentInstances(Iterable<? extends Optional<? extends T>> iterable) {
Preconditions.checkNotNull(iterable);
return new AnonymousClass1(iterable);
}
}