|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.omnaest.utils.structure.element.cached.CachedElement<T>
T - public class CachedElement<T>
A CachedElement provides an abstract cache mechanism around a given value. The value is initially resolved once from a
given CachedElement.ValueResolver.
| Nested Class Summary | |
|---|---|
protected static interface |
CachedElement.CachedValue<T>
Used to store and retrieve the CachedElement.CachedValue |
static interface |
CachedElement.ValueResolver<T>
|
static class |
CachedElement.ValueResolverSimple<T>
Simple CachedElement.ValueResolver which returns the object initially given to the constructor. |
| Field Summary | |
|---|---|
protected CachedElement.CachedValue<T> |
cachedValue
|
protected CachedElement.ValueResolver<T> |
valueResolver
|
| Constructor Summary | |
|---|---|
CachedElement(CachedElement.ValueResolver<T> valueResolver)
|
|
CachedElement(T value)
|
|
| Method Summary | |
|---|---|
CachedElement<T> |
clearCache()
Clears the cached value, so the next call to getValue() will resolve the value once again from the underlying
CachedElement.ValueResolver. |
T |
getValue()
Returns the value from the cache or resolves it from the underlying CachedElement.ValueResolver if it is null. |
T |
getValueFromCacheOnly()
Returns the cached value and does not resolve the value if the cached value is null. |
CachedElement.ValueResolver<T> |
getValueResolver()
|
boolean |
hasValueResolved()
Returns true, if the cache has resolved a value from the underlying CachedElement.ValueResolver instance. |
protected CachedElement.CachedValue<T> |
newCachedValue()
Creates a new CachedElement.CachedValue instance. |
void |
setValueResolver(CachedElement.ValueResolver<T> valueResolver)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected CachedElement.CachedValue<T> cachedValue
protected CachedElement.ValueResolver<T> valueResolver
| Constructor Detail |
|---|
public CachedElement(CachedElement.ValueResolver<T> valueResolver)
valueResolver - CachedElement,
CachedElement.ValueResolverpublic CachedElement(T value)
value - CachedElement,
CachedElement.ValueResolver,
CachedElement.ValueResolverSimple| Method Detail |
|---|
public T getValue()
CachedElement.ValueResolver if it is null.
getValueFromCacheOnly()public T getValueFromCacheOnly()
getValue() for normal purposes.
getValue()public boolean hasValueResolved()
CachedElement.ValueResolver instance.
public void setValueResolver(CachedElement.ValueResolver<T> valueResolver)
public CachedElement.ValueResolver<T> getValueResolver()
public CachedElement<T> clearCache()
getValue() will resolve the value once again from the underlying
CachedElement.ValueResolver.
protected CachedElement.CachedValue<T> newCachedValue()
CachedElement.CachedValue instance. Override this to alternate the behavior of the CachedElement
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||