
de.tsl2.nano.historize.SVolatile Maven / Gradle / Ivy
package de.tsl2.nano.historize;
import java.util.function.Supplier;
/**
* use {@link Volatile} only the {@link Supplier} to eval new value on expiring.
*
* NOTE: the use of {@link #setHardResetOnExpiring(boolean)} and
* {@link #set(Object)} may result in unpredicted results!
*
* @author ts
*/
public class SVolatile extends Volatile {
private Supplier callbackNewValue;
public SVolatile(long period, Supplier callbackNewValue) {
super(period, null);
this.callbackNewValue = callbackNewValue;
}
@Override
public T get() {
return super.get(callbackNewValue);
}
@Override
public T get(Supplier newValueOnExpired) {
throw new UnsupportedOperationException("please call the get() method without parameter");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy