/* * Decompiled with CFR 0.152. * * Could not load the following classes: * org.jspecify.annotations.Nullable */ package net.minecraft.server.level; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; import org.jspecify.annotations.Nullable; public interface ChunkResult { public static ChunkResult of(T value) { return new Success(value); } public static ChunkResult error(String error) { return ChunkResult.error(() -> error); } public static ChunkResult error(Supplier errorSupplier) { return new Fail(errorSupplier); } public boolean isSuccess(); public @Nullable T orElse(@Nullable T var1); public static @Nullable R orElse(ChunkResult chunkResult, @Nullable R orElse) { R result = chunkResult.orElse(null); return result != null ? result : (R)orElse; } public @Nullable String getError(); public ChunkResult ifSuccess(Consumer var1); public ChunkResult map(Function var1); public T orElseThrow(Supplier var1) throws E; public record Success(T value) implements ChunkResult { @Override public boolean isSuccess() { return true; } @Override public T orElse(@Nullable T orElse) { return this.value; } @Override public @Nullable String getError() { return null; } @Override public ChunkResult ifSuccess(Consumer consumer) { consumer.accept(this.value); return this; } @Override public ChunkResult map(Function map) { return new Success(map.apply(this.value)); } @Override public T orElseThrow(Supplier exceptionSupplier) throws E { return this.value; } } public record Fail(Supplier error) implements ChunkResult { @Override public boolean isSuccess() { return false; } @Override public @Nullable T orElse(@Nullable T orElse) { return orElse; } @Override public String getError() { return this.error.get(); } @Override public ChunkResult ifSuccess(Consumer consumer) { return this; } @Override public ChunkResult map(Function map) { return new Fail(this.error); } @Override public T orElseThrow(Supplier exceptionSupplier) throws E { throw (Throwable)exceptionSupplier.get(); } } }