You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
538 B
37 lines
538 B
package mightypork.utils.math.constraints.num;
|
|
|
|
|
|
public class NumCache extends NumAdapter {
|
|
|
|
private final NumVar cache = Num.makeVar();
|
|
private final Num source;
|
|
private boolean inited = false;
|
|
|
|
|
|
public NumCache(Num source) {
|
|
this.source = source;
|
|
}
|
|
|
|
|
|
@Override
|
|
protected Num getSource()
|
|
{
|
|
if (!inited) poll();
|
|
|
|
return cache;
|
|
}
|
|
|
|
|
|
/**
|
|
* Update cached value and cached digest (if digest caching is enabled)
|
|
*/
|
|
@Override
|
|
public void poll()
|
|
{
|
|
inited = true;
|
|
cache.setTo(source);
|
|
|
|
super.poll();
|
|
}
|
|
|
|
}
|
|
|