public class LastKnown<T>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
isValid |
protected double |
msFreshness |
protected ElapsedTime |
timer |
protected T |
value |
| Constructor and Description |
|---|
LastKnown() |
LastKnown(double msFreshness) |
| Modifier and Type | Method and Description |
|---|---|
static <X> LastKnown<X>[] |
createArray(int length) |
T |
getNonTimedValue()
Returns the stored value, w/o using a timer to invalidate
|
T |
getRawValue()
Returns the stored value, whether or not it is valid
|
T |
getValue()
Returns the last known value, or null if not valid
|
void |
invalidate()
Marks the last known value as invalid.
|
static <X> void |
invalidateArray(LastKnown<X>[] array) |
boolean |
isValid()
Returns whether a last value is currently known and is fresh enough.
|
boolean |
isValue(T valueQ)
Answers whether the last known value is both valid and equal to the value indicated.
|
T |
setValue(T value)
If non-null, sets the current value to be the indicated (known) value and resets
the freshness timer.
|
boolean |
updateValue(T valueQ)
If the last known value is not both valid and equal to the indicated value, updates it to be
same and returns true; otherwise, returns false.
|
protected T value
protected boolean isValid
protected ElapsedTime timer
protected double msFreshness
public static <X> LastKnown<X>[] createArray(int length)
public static <X> void invalidateArray(LastKnown<X>[] array)
public void invalidate()
getRawValue(),
getValue()public boolean isValid()
public T getValue()
public T getNonTimedValue()
public T getRawValue()
public T setValue(T value)
invalidate().public boolean isValue(T valueQ)
valueQ - the value queriedpublic boolean updateValue(T valueQ)
valueQ - the value queried