Package org.apache.cayenne.util
Class PersistentObjectMap
java.lang.Object
org.apache.cayenne.util.RelationshipFault
org.apache.cayenne.util.PersistentObjectMap
- All Implemented Interfaces:
Serializable
,Map
,ValueHolder
public class PersistentObjectMap extends RelationshipFault implements Map, ValueHolder
- Since:
- 3.0
- See Also:
- Serialized Form
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field Description protected Accessor
mapKeyAccessor
protected Map
objectMap
Fields inherited from class org.apache.cayenne.util.RelationshipFault
relationshipName, relationshipOwner
-
Constructor Summary
Constructors Constructor Description PersistentObjectMap(Persistent relationshipOwner, String relationshipName, Accessor mapKeyAccessor)
Creates PersistentObjectList initializing it with list owner persistent object and relationship name that this list maps to. -
Method Summary
Modifier and Type Method Description void
clear()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
Set
entrySet()
Object
get(Object key)
Object
getValue()
Returns an object stored by this ValueHolder.Object
getValueDirectly()
Retrieves ValueHolder value without triggering fault resolution.protected Map
indexCollection(Collection<Object> collection)
Converts a collection into a map indexed by map key.void
invalidate()
Turns a ValueHolder into a fault.boolean
isEmpty()
boolean
isFault()
Returns true if the internal value is not yet resolved.Set
keySet()
protected void
mergeLocalChanges(List resolved)
protected void
postprocessAdd(Object addedObject)
protected void
postprocessAdd(Collection collection)
protected void
postprocessRemove(Object removedObject)
protected void
postprocessRemove(Collection collection)
Object
put(Object key, Object value)
void
putAll(Map map)
void
putDirectly(Object key, Object value)
Object
remove(Object key)
void
removeDirectly(Object key)
protected Map
resolvedObjectMap()
Returns internal objects list resolving it if needed.void
setObjectMap(Map objectMap)
Object
setValue(Object value)
Sets an object stored by this ValueHolder.Object
setValueDirectly(Object value)
Sets ValueHolder vaue without triggering fault resolution.int
size()
String
toString()
Collection
values()
Methods inherited from class org.apache.cayenne.util.RelationshipFault
getRelationshipName, getRelationshipOwner, isTransientParent, isUncommittedParent, resolveFromDB, updateReverse
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
-
objectMap
-
mapKeyAccessor
-
-
Constructor Details
-
PersistentObjectMap
public PersistentObjectMap(Persistent relationshipOwner, String relationshipName, Accessor mapKeyAccessor)Creates PersistentObjectList initializing it with list owner persistent object and relationship name that this list maps to.- Parameters:
relationshipOwner
- persistent object that owns this list.relationshipName
- a query used to resolve the listmapKeyAccessor
- an accessor that can read a map key from an object.
-
-
Method Details
-
getValue
Description copied from interface:ValueHolder
Returns an object stored by this ValueHolder.- Specified by:
getValue
in interfaceValueHolder
- Throws:
CayenneRuntimeException
-
getValueDirectly
Description copied from interface:ValueHolder
Retrieves ValueHolder value without triggering fault resolution.- Specified by:
getValueDirectly
in interfaceValueHolder
- Throws:
CayenneRuntimeException
-
invalidate
public void invalidate()Description copied from interface:ValueHolder
Turns a ValueHolder into a fault.- Specified by:
invalidate
in interfaceValueHolder
-
mergeLocalChanges
- Specified by:
mergeLocalChanges
in classRelationshipFault
-
isFault
public boolean isFault()Description copied from interface:ValueHolder
Returns true if the internal value is not yet resolved.- Specified by:
isFault
in interfaceValueHolder
-
setValue
Description copied from interface:ValueHolder
Sets an object stored by this ValueHolder.- Specified by:
setValue
in interfaceValueHolder
- Parameters:
value
- a new value of the ValueHolder.- Returns:
- a previous value saved in the ValueHolder.
- Throws:
CayenneRuntimeException
-
setValueDirectly
Description copied from interface:ValueHolder
Sets ValueHolder vaue without triggering fault resolution.- Specified by:
setValueDirectly
in interfaceValueHolder
- Throws:
CayenneRuntimeException
-
setObjectMap
-
resolvedObjectMap
Returns internal objects list resolving it if needed. -
indexCollection
Converts a collection into a map indexed by map key. -
toString
-
postprocessAdd
-
postprocessAdd
-
postprocessRemove
-
postprocessRemove
-
clear
public void clear() -
containsKey
- Specified by:
containsKey
in interfaceMap
-
containsValue
- Specified by:
containsValue
in interfaceMap
-
entrySet
-
get
-
isEmpty
public boolean isEmpty() -
keySet
-
put
-
putAll
-
remove
-
size
public int size() -
values
-
putDirectly
-
removeDirectly
-