Package cz.cvut.kbss.jopa.proxy.lazy
Class LazyLoadingMapProxy<T,K,V>
java.lang.Object
cz.cvut.kbss.jopa.proxy.lazy.LazyLoadingMapProxy<T,K,V>
- Type Parameters:
T
- Type of the object whose attribute value is this map proxyK
- Map key typeV
- Map value type
- All Implemented Interfaces:
LazyLoadingProxy<Map<K,
,V>> Map<K,
V>
public class LazyLoadingMapProxy<T,K,V>
extends Object
implements LazyLoadingProxy<Map<K,V>>, Map<K,V>
Map
proxy that triggers lazy loading when its contents is accessed.-
Nested Class Summary
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final FieldSpecification<? super T,
Map<K, V>> protected final T
protected final UnitOfWork
-
Constructor Summary
ConstructorsConstructorDescriptionLazyLoadingMapProxy
(T owner, FieldSpecification<? super T, Map<K, V>> fieldSpec, UnitOfWork persistenceContext) -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
If this proxy has already been loaded, this method returns the loaded value.boolean
isEmpty()
boolean
isLoaded()
Checks whether this proxy has already been loaded.keySet()
void
int
size()
toString()
Triggers value loading.unwrap()
Gets a value that should be used to replace this proxy outside a persistence context.values()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
owner
-
fieldSpec
-
persistenceContext
-
-
Constructor Details
-
LazyLoadingMapProxy
public LazyLoadingMapProxy(T owner, FieldSpecification<? super T, Map<K, V>> fieldSpec, UnitOfWork persistenceContext)
-
-
Method Details
-
triggerLazyLoading
Description copied from interface:LazyLoadingProxy
Triggers value loading.- Specified by:
triggerLazyLoading
in interfaceLazyLoadingProxy<T>
- Returns:
- Loaded value
-
isLoaded
public boolean isLoaded()Description copied from interface:LazyLoadingProxy
Checks whether this proxy has already been loaded.- Specified by:
isLoaded
in interfaceLazyLoadingProxy<T>
- Returns:
true
if this proxy has been loaded,false
otherwise
-
getLoadedValue
Description copied from interface:LazyLoadingProxy
If this proxy has already been loaded, this method returns the loaded value.- Specified by:
getLoadedValue
in interfaceLazyLoadingProxy<T>
- Returns:
- The loaded value,
null
if this proxy has not been loaded, yet - See Also:
-
unwrap
Description copied from interface:LazyLoadingProxy
Gets a value that should be used to replace this proxy outside a persistence context.- Specified by:
unwrap
in interfaceLazyLoadingProxy<T>
- Returns:
- Default value to replace this proxy with
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<T,
K>
-
containsValue
- Specified by:
containsValue
in interfaceMap<T,
K>
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-
entrySet
-
toString
-