public class CachingTypedPropertyMap<T> extends TypedPropertyMap<T>
Extends the TypedPropertyMap by caching the values instead of converting all the time.
Changes directly in the source map will not be detected unless an explicit refresh() is done.
Changes through the CachingTypedPropertyMap should not be a problem.
Note: Only call for the registered type will be cached, that means that direct
calls to TypedPropertyMap.getValue(Object, Class) will always use the conversionService.
TypedPropertyMappropertyTypeRegistry, source, sourceValueClass| Constructor and Description |
|---|
CachingTypedPropertyMap(PropertyTypeRegistry<T> propertyTypeRegistry,
Map<T,?> source,
Class sourceValueClass) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
TypedPropertyMap<T> |
detach()
Creates a duplicate of the TypedPropertyMap with its own property source, but the
same registry and conversionService.
|
<O> O |
getValue(T property)
Allows a strong typed property to be fetched from the source map.
|
void |
refresh()
Clears all cached values, ensuring that on the next request the properties will be converted again.
|
Object |
remove(Object key) |
Object |
set(T property,
Object value)
Stores the property value in the source map by converting it to the sourceValueClass first.
|
containsKey, containsValue, entrySet, get, getSource, getValue, getValue, isEmpty, keySet, put, putAll, size, valuesclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAllpublic CachingTypedPropertyMap(PropertyTypeRegistry<T> propertyTypeRegistry, Map<T,?> source, Class sourceValueClass)
public <O> O getValue(T property)
TypedPropertyMapgetValue in class TypedPropertyMap<T>O - Strong type value to return, the must registered type for the property must be able to cast to this type!property - Key of the property.public Object set(T property, Object value)
TypedPropertyMapset in class TypedPropertyMap<T>property - Key of the property.value - Strong type value to set the property to.public void clear()
public void refresh()
public TypedPropertyMap<T> detach()
detach in class TypedPropertyMap<T>Copyright © 2017. All rights reserved.