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
-
-
Field Summary
Fields Modifier and Type Field Description protected AccessormapKeyAccessorprotected MapobjectMap-
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleancontainsKey(Object key)booleancontainsValue(Object value)SetentrySet()Objectget(Object key)ObjectgetValue()Returns an object stored by this ValueHolder.ObjectgetValueDirectly()Retrieves ValueHolder value without triggering fault resolution.protected MapindexCollection(Collection<Object> collection)Converts a collection into a map indexed by map key.voidinvalidate()Turns a ValueHolder into a fault.booleanisEmpty()booleanisFault()Returns true if the internal value is not yet resolved.SetkeySet()protected voidmergeLocalChanges(List resolved)protected voidpostprocessAdd(Object addedObject)protected voidpostprocessAdd(Collection collection)protected voidpostprocessRemove(Object removedObject)protected voidpostprocessRemove(Collection collection)Objectput(Object key, Object value)voidputAll(Map map)voidputDirectly(Object key, Object value)Objectremove(Object key)voidremoveDirectly(Object key)protected MapresolvedObjectMap()Returns internal objects list resolving it if needed.voidsetObjectMap(Map objectMap)ObjectsetValue(Object value)Sets an object stored by this ValueHolder.ObjectsetValueDirectly(Object value)Sets ValueHolder vaue without triggering fault resolution.intsize()StringtoString()Collectionvalues()-
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
-
-
-
-
Constructor Detail
-
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 Detail
-
getValue
public Object getValue() throws CayenneRuntimeException
Description copied from interface:ValueHolderReturns an object stored by this ValueHolder.- Specified by:
getValuein interfaceValueHolder- Throws:
CayenneRuntimeException
-
getValueDirectly
public Object getValueDirectly() throws CayenneRuntimeException
Description copied from interface:ValueHolderRetrieves ValueHolder value without triggering fault resolution.- Specified by:
getValueDirectlyin interfaceValueHolder- Throws:
CayenneRuntimeException
-
invalidate
public void invalidate()
Description copied from interface:ValueHolderTurns a ValueHolder into a fault.- Specified by:
invalidatein interfaceValueHolder
-
mergeLocalChanges
protected void mergeLocalChanges(List resolved)
- Specified by:
mergeLocalChangesin classRelationshipFault
-
isFault
public boolean isFault()
Description copied from interface:ValueHolderReturns true if the internal value is not yet resolved.- Specified by:
isFaultin interfaceValueHolder
-
setValue
public Object setValue(Object value) throws CayenneRuntimeException
Description copied from interface:ValueHolderSets an object stored by this ValueHolder.- Specified by:
setValuein interfaceValueHolder- Parameters:
value- a new value of the ValueHolder.- Returns:
- a previous value saved in the ValueHolder.
- Throws:
CayenneRuntimeException
-
setValueDirectly
public Object setValueDirectly(Object value) throws CayenneRuntimeException
Description copied from interface:ValueHolderSets ValueHolder vaue without triggering fault resolution.- Specified by:
setValueDirectlyin interfaceValueHolder- Throws:
CayenneRuntimeException
-
setObjectMap
public void setObjectMap(Map objectMap)
-
resolvedObjectMap
protected Map resolvedObjectMap()
Returns internal objects list resolving it if needed.
-
indexCollection
protected Map indexCollection(Collection<Object> collection)
Converts a collection into a map indexed by map key.
-
postprocessAdd
protected void postprocessAdd(Object addedObject)
-
postprocessAdd
protected void postprocessAdd(Collection collection)
-
postprocessRemove
protected void postprocessRemove(Object removedObject)
-
postprocessRemove
protected void postprocessRemove(Collection collection)
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap
-
values
public Collection values()
-
removeDirectly
public void removeDirectly(Object key)
-
-