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>
,SequencedCollection<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:
-
Field Summary
Fields inherited from class org.apache.cayenne.util.RelationshipFault
relationshipName, relationshipOwner
-
Constructor Summary
ConstructorDescriptionPersistentObjectList
(Persistent relationshipOwner, String relationshipName) Creates PersistentObjectList initializing it with list owner persistent object and relationship name that this list maps to. -
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
boolean
addAll
(int index, Collection<? extends E> c) boolean
addAll
(Collection<? extends E> c) void
addDirectly
(E target) Adds an object without triggering an eventprotected boolean
void
clear()
protected void
boolean
boolean
boolean
get
(int index) getValue()
Returns an object stored by this ValueHolder.Retrieves ValueHolder value without triggering fault resolution.int
hashCode()
int
void
Turns itself into a fault, thus forcing a refresh on the next access.boolean
isEmpty()
boolean
isFault()
Returns whether this list is not yet resolved and requires a fetch.iterator()
int
listIterator
(int index) protected void
mergeLocalChanges
(List<E> fetchedList) protected void
postprocessAdd
(E addedObject) protected void
postprocessAdd
(Collection<? extends E> collection) protected void
postprocessRemove
(E removedObject) protected void
postprocessRemove
(Collection<? extends E> collection) remove
(int index) boolean
boolean
removeAll
(Collection<?> c) void
removeDirectly
(E target) Removes an object without triggering an eventprotected boolean
removeLocal
(E object) Returns internal objects list resolving it if needed.boolean
retainAll
(Collection<?> c) void
setObjectList
(List<E> objectList) Sets an object stored by this ValueHolder.setValueDirectly
(List<E> value) Sets ValueHolder vaue without triggering fault resolution.protected boolean
int
size()
subList
(int fromIndex, int toIndex) Object[]
toArray()
<T> T[]
toArray
(T[] a) toString()
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
addFirst, addLast, getFirst, getLast, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
-
Field Details
-
objectList
-
addedToUnresolved
-
removedFromUnresolved
-
-
Constructor Details
-
PersistentObjectList
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 Details
-
isFault
public boolean isFault()Returns whether this list is not yet resolved and requires a fetch.- Specified by:
isFault
in interfaceValueHolder<E>
-
invalidate
public void invalidate()Turns itself into a fault, thus forcing a refresh on the next access.- Specified by:
invalidate
in interfaceValueHolder<E>
-
setValueDirectly
Description copied from interface:ValueHolder
Sets ValueHolder vaue without triggering fault resolution.- Specified by:
setValueDirectly
in interfaceValueHolder<E>
- Throws:
CayenneRuntimeException
-
getValue
Description copied from interface:ValueHolder
Returns an object stored by this ValueHolder.- Specified by:
getValue
in interfaceValueHolder<E>
- Throws:
CayenneRuntimeException
-
getValueDirectly
Description copied from interface:ValueHolder
Retrieves ValueHolder value without triggering fault resolution.- Specified by:
getValueDirectly
in interfaceValueHolder<E>
- Throws:
CayenneRuntimeException
-
setValue
Description copied from interface:ValueHolder
Sets an object stored by this ValueHolder.- Specified by:
setValue
in interfaceValueHolder<E>
- Parameters:
value
- a new value of the ValueHolder.- Returns:
- a previous value saved in the ValueHolder.
- Throws:
CayenneRuntimeException
-
setObjectList
-
add
-
add
-
addAll
-
addAll
-
clear
public void clear() -
contains
-
containsAll
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceList<E>
-
equals
-
hashCode
public int hashCode() -
get
-
indexOf
-
isEmpty
public boolean isEmpty() -
iterator
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceList<E>
-
listIterator
- Specified by:
listIterator
in interfaceList<E>
-
listIterator
- Specified by:
listIterator
in interfaceList<E>
-
remove
-
remove
-
removeAll
-
retainAll
-
set
-
size
public int size() -
subList
-
toArray
-
toArray
public <T> T[] toArray(T[] a) -
resolvedObjectList
Returns internal objects list resolving it if needed. -
clearLocalChanges
protected void clearLocalChanges() -
mergeLocalChanges
- Specified by:
mergeLocalChanges
in classRelationshipFault<E>
-
addLocal
-
removeLocal
-
shouldAddToRemovedFromUnresolvedList
- Returns:
- whether object should be added to
removedFromUnresolved
during removal
-
postprocessAdd
-
postprocessRemove
-
postprocessAdd
-
postprocessRemove
-
toString
-
addDirectly
Description copied from interface:PersistentObjectCollection
Adds an object without triggering an event- Specified by:
addDirectly
in interfacePersistentObjectCollection<E>
-
removeDirectly
Description copied from interface:PersistentObjectCollection
Removes an object without triggering an event- Specified by:
removeDirectly
in interfacePersistentObjectCollection<E>
-