// Path: src/main/java/org/dataloader/impl/Assertions.java
// public static <T> T nonNull(T t) {
//     return nonNull(t, () -> "nonNull object required");
// }


import org.dataloader.annotations.PublicApi;
import java.util.Optional;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import static org.dataloader.impl.Assertions.nonNull;
package org.dataloader;




/**
 * Try is class that allows you to hold the result of computation or the throwable it produced.
 *
 * This class is useful in {@link org.dataloader.BatchLoader}s so you can mix a batch of calls where some of
 * the calls succeeded and some of them failed.  You would make your batch loader declaration like :
 *
 * <pre>
 * {@code BatchLoader<K,Try<V> batchLoader = new BatchLoader() { ... } }
 * </pre>
 *
 * {@link org.dataloader.DataLoader} understands the use of Try and will take the exceptional path and complete
 * the value promise with that exception value.
 */
@PublicApi
public class Try<V> {
    private final static Object NIL = new Object() {
    };

    private final static Throwable NIL_THROWABLE = new RuntimeException() {
        @Override
        public String getMessage() {
            return "failure";
        }

        @Override
        public synchronized Throwable fillInStackTrace() {
            return this;
        }
    };


    private final Throwable throwable;
    private final V value;


    @SuppressWarnings("unchecked")
    private Try(Throwable throwable) {
// Path: src/main/java/org/dataloader/impl/Assertions.java
// public static <T> T nonNull(T t) {
//     return nonNull(t, () -> "nonNull object required");
// }


// Path: src/main/java/org/dataloader/Try.java
import org.dataloader.annotations.PublicApi;
import java.util.Optional;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
import static org.dataloader.impl.Assertions.nonNull;

package org.dataloader;




/**
 * Try is class that allows you to hold the result of computation or the throwable it produced.
 *
 * This class is useful in {@link org.dataloader.BatchLoader}s so you can mix a batch of calls where some of
 * the calls succeeded and some of them failed.  You would make your batch loader declaration like :
 *
 * <pre>
 * {@code BatchLoader<K,Try<V> batchLoader = new BatchLoader() { ... } }
 * </pre>
 *
 * {@link org.dataloader.DataLoader} understands the use of Try and will take the exceptional path and complete
 * the value promise with that exception value.
 */
@PublicApi
public class Try<V> {
    private final static Object NIL = new Object() {
    };

    private final static Throwable NIL_THROWABLE = new RuntimeException() {
        @Override
        public String getMessage() {
            return "failure";
        }

        @Override
        public synchronized Throwable fillInStackTrace() {
            return this;
        }
    };


    private final Throwable throwable;
    private final V value;


    @SuppressWarnings("unchecked")
    private Try(Throwable throwable) {
        this.throwable = nonNull(throwable);