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

com.zeroleak.throwingsupplier.Either 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;

public class Either {
  private Optional value;
  private Optional fallback;

  public Either(T value) {
    this(Optional.of(value), Optional.empty());
  }

  public Either(Optional emptyValue, U fallback) {
    this(Optional.empty(), Optional.of(fallback));
  }

  private Either(Optional value, Optional fallback) {
    this.value = value;
    this.fallback = fallback;
  }

  public Optional getValue() {
    return value;
  }

  public Optional getFallback() {
    return fallback;
  }
}