com.zeroleak.throwingsupplier.LastValueFallbackSupplier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of throwing-supplier Show documentation
Show all versions of throwing-supplier Show documentation
Guava cache supplier extension to memoize exceptions, fallback, expiration control.
The newest version!
package com.zeroleak.throwingsupplier;
public abstract class LastValueFallbackSupplier
extends ThrowingSupplier {
private Throwing lastValue; // last non-throwing value
@Override
public Throwing get() {
Throwing value = super.get();
if (value.getValue().isPresent()) {
// value found => update lastValue
this.lastValue = value;
return value;
} else {
// value not found => return lastValue
if (this.lastValue != null) {
return lastValue;
}
// no lastValue => return throwing value
return value;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy