Package org.apache.cayenne.util
Class PersistentObjectList<E>
- java.lang.Object
-
- org.apache.cayenne.util.RelationshipFault<E>
-
- org.apache.cayenne.util.PersistentObjectList<E>
-
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,List<E>,PersistentObjectCollection<E>,ValueHolder<List<E>>
- Direct Known Subclasses:
ToManyList
public class PersistentObjectList<E> extends RelationshipFault<E> implements List<E>, ValueHolder<List<E>>, PersistentObjectCollection<E>
A list of persistent objects lazily resolved on the first access.- Since:
- 1.2
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected LinkedList<E>addedToUnresolvedprotected List<E>objectListprotected LinkedList<E>removedFromUnresolved-
Fields inherited from class org.apache.cayenne.util.RelationshipFault
relationshipName, relationshipOwner
-
-
Constructor Summary
Constructors Constructor Description PersistentObjectList(Persistent relationshipOwner, String relationshipName)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 voidadd(int index, E o)booleanadd(E o)booleanaddAll(int index, Collection<? extends E> c)booleanaddAll(Collection<? extends E> c)voidaddDirectly(E target)Adds an object without triggering an eventprotected booleanaddLocal(E object)voidclear()protected voidclearLocalChanges()booleancontains(Object o)booleancontainsAll(Collection c)booleanequals(Object o)Eget(int index)List<E>getValue()Returns an object stored by this ValueHolder.List<E>getValueDirectly()Retrieves ValueHolder value without triggering fault resolution.inthashCode()intindexOf(Object o)voidinvalidate()Turns itself into a fault, thus forcing a refresh on the next access.booleanisEmpty()booleanisFault()Returns whether this list is not yet resolved and requires a fetch.Iterator<E>iterator()intlastIndexOf(Object o)ListIterator<E>listIterator()ListIterator<E>listIterator(int index)protected voidmergeLocalChanges(List<E> fetchedList)protected voidpostprocessAdd(E addedObject)protected voidpostprocessAdd(Collection<? extends E> collection)protected voidpostprocessRemove(E removedObject)protected voidpostprocessRemove(Collection<? extends E> collection)Eremove(int index)booleanremove(Object o)booleanremoveAll(Collection<?> c)voidremoveDirectly(E target)Removes an object without triggering an eventprotected booleanremoveLocal(E object)protected List<E>resolvedObjectList()Returns internal objects list resolving it if needed.booleanretainAll(Collection<?> c)Eset(int index, E o)voidsetObjectList(List<E> objectList)List<E>setValue(List<E> value)Sets an object stored by this ValueHolder.List<E>setValueDirectly(List<E> value)Sets ValueHolder vaue without triggering fault resolution.protected booleanshouldAddToRemovedFromUnresolvedList(E object)intsize()List<E>subList(int fromIndex, int toIndex)Object[]toArray()<T> T[]toArray(T[] a)StringtoString()-
Methods inherited from class org.apache.cayenne.util.RelationshipFault
getRelationshipName, getRelationshipOwner, isTransientParent, isUncommittedParent, resolveFromDB, updateReverse
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
replaceAll, sort, spliterator
-
-
-
-
Field Detail
-
addedToUnresolved
protected LinkedList<E> addedToUnresolved
-
removedFromUnresolved
protected LinkedList<E> removedFromUnresolved
-
-
Constructor Detail
-
PersistentObjectList
public PersistentObjectList(Persistent relationshipOwner, String relationshipName)
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 list
-
-
Method Detail
-
isFault
public boolean isFault()
Returns whether this list is not yet resolved and requires a fetch.- Specified by:
isFaultin interfaceValueHolder<E>
-
invalidate
public void invalidate()
Turns itself into a fault, thus forcing a refresh on the next access.- Specified by:
invalidatein interfaceValueHolder<E>
-
setValueDirectly
public List<E> setValueDirectly(List<E> value) throws CayenneRuntimeException
Description copied from interface:ValueHolderSets ValueHolder vaue without triggering fault resolution.- Specified by:
setValueDirectlyin interfaceValueHolder<E>- Throws:
CayenneRuntimeException
-
getValue
public List<E> getValue() throws CayenneRuntimeException
Description copied from interface:ValueHolderReturns an object stored by this ValueHolder.- Specified by:
getValuein interfaceValueHolder<E>- Throws:
CayenneRuntimeException
-
getValueDirectly
public List<E> getValueDirectly() throws CayenneRuntimeException
Description copied from interface:ValueHolderRetrieves ValueHolder value without triggering fault resolution.- Specified by:
getValueDirectlyin interfaceValueHolder<E>- Throws:
CayenneRuntimeException
-
setValue
public List<E> setValue(List<E> value) throws CayenneRuntimeException
Description copied from interface:ValueHolderSets an object stored by this ValueHolder.- Specified by:
setValuein interfaceValueHolder<E>- Parameters:
value- a new value of the ValueHolder.- Returns:
- a previous value saved in the ValueHolder.
- Throws:
CayenneRuntimeException
-
add
public boolean add(E o)
-
addAll
public boolean addAll(Collection<? extends E> c)
-
addAll
public boolean addAll(int index, Collection<? extends E> c)
-
clear
public void clear()
-
contains
public boolean contains(Object o)
-
containsAll
public boolean containsAll(Collection c)
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceList<E>
-
equals
public boolean equals(Object o)
-
hashCode
public int hashCode()
-
isEmpty
public boolean isEmpty()
-
lastIndexOf
public int lastIndexOf(Object o)
- Specified by:
lastIndexOfin interfaceList<E>
-
listIterator
public ListIterator<E> listIterator()
- Specified by:
listIteratorin interfaceList<E>
-
listIterator
public ListIterator<E> listIterator(int index)
- Specified by:
listIteratorin interfaceList<E>
-
remove
public boolean remove(Object o)
-
removeAll
public boolean removeAll(Collection<?> c)
-
retainAll
public boolean retainAll(Collection<?> c)
-
size
public int size()
-
toArray
public Object[] toArray()
-
toArray
public <T> T[] toArray(T[] a)
-
resolvedObjectList
protected List<E> resolvedObjectList()
Returns internal objects list resolving it if needed.
-
clearLocalChanges
protected void clearLocalChanges()
-
mergeLocalChanges
protected void mergeLocalChanges(List<E> fetchedList)
- Specified by:
mergeLocalChangesin classRelationshipFault<E>
-
addLocal
protected boolean addLocal(E object)
-
removeLocal
protected boolean removeLocal(E object)
-
shouldAddToRemovedFromUnresolvedList
protected boolean shouldAddToRemovedFromUnresolvedList(E object)
- Returns:
- whether object should be added to
removedFromUnresolvedduring removal
-
postprocessAdd
protected void postprocessAdd(Collection<? extends E> collection)
-
postprocessRemove
protected void postprocessRemove(Collection<? extends E> collection)
-
postprocessAdd
protected void postprocessAdd(E addedObject)
-
postprocessRemove
protected void postprocessRemove(E removedObject)
-
addDirectly
public void addDirectly(E target)
Description copied from interface:PersistentObjectCollectionAdds an object without triggering an event- Specified by:
addDirectlyin interfacePersistentObjectCollection<E>
-
removeDirectly
public void removeDirectly(E target)
Description copied from interface:PersistentObjectCollectionRemoves an object without triggering an event- Specified by:
removeDirectlyin interfacePersistentObjectCollection<E>
-
-