All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zeroleak.throwingsupplier.Throwing Maven / Gradle / Ivy

Go to download

Guava cache supplier extension to memoize exceptions, fallback, expiration control.

The newest version!
package com.zeroleak.throwingsupplier;

import java8.util.Optional;
import java8.util.function.Supplier;

public class Throwing extends Either {

  public Throwing(T value) {
    super(value);
  }

  public Throwing(Exception e) {
    super((Optional) Optional.empty(), (E) e);
  }

  public T getOrThrow() throws Exception {
    return getValue()
        .orElseThrow(
            new Supplier() {
              @Override
              public Exception get() {
                return getFallback().get();
              }
            });
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy