ToManyList (cayenne-doc: Cayenne Documentation 5.0-M2 API)
Description: declaration: package: org.apache.cayenne.access, class: ToManyList

# Class ToManyList<E>

java.lang.Object
org.apache.cayenne.util.RelationshipFault<E>
org.apache.cayenne.util.PersistentObjectList<E>
org.apache.cayenne.access.ToManyList<E>

All Implemented Interfaces:
  `Serializable, Iterable<E>, Collection<E>, List<E>, SequencedCollection<E>, PersistentObjectCollection<E>, ValueHolder<List<E>>`

public class ToManyList<E> extends PersistentObjectList<E> implements Serializable
A list that holds objects for to-many relationships. All operations, except for resolving the list from DB, are not synchronized. The safest way to implement custom synchronization is to synchronize on parent ObjectStore.

See Also:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from class PersistentObjectList

  `addedToUnresolved, objectList, removedFromUnresolved`
  Modifier and Type
  Field
  Description
  `protected LinkedList<E>`
  `addedToUnresolved`
  `protected List<E>`
  `objectList`
  `protected LinkedList<E>`
  `removedFromUnresolved`

  ### Fields inherited from class RelationshipFault

  `relationshipName, relationshipOwner`
  Modifier and Type
  Field
  Description
  `protected String`
  `relationshipName`
  `protected Persistent`
  `relationshipOwner`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ToManyList(Persistent source, String relationship)`
  Creates ToManyList.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `hashCode()`
  `protected void`
  `postprocessAdd(E addedObject)`
  `protected void`
  `postprocessAdd(Collection<? extends E> collection)`
  `protected void`
  `postprocessRemove(E removedObject)`
  `protected void`
  `postprocessRemove(Collection<? extends E> collection)`
  `protected boolean`
  `shouldAddToRemovedFromUnresolvedList(Object object)`
  `String`
  `toString()`
  `protected void`
  `updateReverse(List<E> resolved)`

  ### Methods inherited from class PersistentObjectList

  `add, add, addAll, addAll, addDirectly, addLocal, clear, clearLocalChanges, contains, containsAll, equals, get, getValue, getValueDirectly, indexOf, invalidate, isEmpty, isFault, iterator, lastIndexOf, listIterator, listIterator, mergeLocalChanges, remove, remove, removeAll, removeDirectly, removeLocal, resolvedObjectList, retainAll, set, setObjectList, setValue, setValueDirectly, size, subList, toArray, toArray`
  Modifier and Type
  Method
  Description
  `void`
  `add(int index, E o)`
  `boolean`
  `add(E o)`
  `boolean`
  `addAll(int index, Collection<? extends E> c)`
  `boolean`
  `addAll(Collection<? extends E> c)`
  `void`
  `addDirectly(E target)`
  Adds an object without triggering an event
  `protected boolean`
  `addLocal(E object)`
  `void`
  `clear()`
  `protected void`
  `clearLocalChanges()`
  `boolean`
  `contains(Object o)`
  `boolean`
  `containsAll(Collection c)`
  `boolean`
  `equals(Object o)`
  `E`
  `get(int index)`
  `List<E>`
  `getValue()`
  Returns an object stored by this ValueHolder.
  `List<E>`
  `getValueDirectly()`
  Retrieves ValueHolder value without triggering fault resolution.
  `int`
  `indexOf(Object o)`
  `void`
  `invalidate()`
  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<E>`
  `iterator()`
  `int`
  `lastIndexOf(Object o)`
  `ListIterator<E>`
  `listIterator()`
  `ListIterator<E>`
  `listIterator(int index)`
  `protected void`
  `mergeLocalChanges(List<E> fetchedList)`
  `E`
  `remove(int index)`
  `boolean`
  `remove(Object o)`
  `boolean`
  `removeAll(Collection<?> c)`
  `void`
  `removeDirectly(E target)`
  Removes an object without triggering an event
  `protected boolean`
  `removeLocal(E object)`
  `protected List<E>`
  `resolvedObjectList()`
  Returns internal objects list resolving it if needed.
  `boolean`
  `retainAll(Collection<?> c)`
  `E`
  `set(int index, E o)`
  `void`
  `setObjectList(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.
  `int`
  `size()`
  `List<E>`
  `subList(int fromIndex, int toIndex)`
  `Object[]`
  `toArray()`
  `<T> T[]`
  `toArray(T[] a)`

  ### Methods inherited from class RelationshipFault

  `getRelationshipName, getRelationshipOwner, isTransientParent, isUncommittedParent, resolveFromDB`
  Modifier and Type
  Method
  Description
  `String`
  `getRelationshipName()`
  `Persistent`
  `getRelationshipOwner()`
  `protected boolean`
  `isTransientParent()`
  `protected boolean`
  `isUncommittedParent()`
  `protected List<E>`
  `resolveFromDB()`
  Executes a query that returns related objects.

  ### Methods inherited from class Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface Collection

  `parallelStream, removeIf, stream, toArray`

  ### Methods inherited from interface Iterable

  `forEach`

  ### Methods inherited from interface List

  `addFirst, addLast, getFirst, getLast, removeFirst, removeLast, replaceAll, reversed, sort, spliterator`

- ## Constructor Details

  - ### ToManyList

    public ToManyList(Persistent source, String relationship)
    Creates ToManyList.
    Since:
      1.1

- ## Method Details

  - ### hashCode

    public int hashCode()
    Specified by:
      `hashCode` in interface `Collection<E>`
    Specified by:
      `hashCode` in interface `List<E>`
    Overrides:
      `hashCode` in class `PersistentObjectList<E>`

  - ### shouldAddToRemovedFromUnresolvedList

    protected boolean shouldAddToRemovedFromUnresolvedList(Object object)
    Overrides:
      `shouldAddToRemovedFromUnresolvedList` in class `PersistentObjectList<E>`
    Returns:
      whether object should be added to `PersistentObjectList.removedFromUnresolved` during removal

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `PersistentObjectList<E>`

  - ### postprocessAdd

    protected void postprocessAdd(Collection<? extends E> collection)
    Overrides:
      `postprocessAdd` in class `PersistentObjectList<E>`

  - ### postprocessRemove

    protected void postprocessRemove(Collection<? extends E> collection)
    Overrides:
      `postprocessRemove` in class `PersistentObjectList<E>`

  - ### postprocessAdd

    protected void postprocessAdd(E addedObject)
    Overrides:
      `postprocessAdd` in class `PersistentObjectList<E>`

  - ### postprocessRemove

    protected void postprocessRemove(E removedObject)
    Overrides:
      `postprocessRemove` in class `PersistentObjectList<E>`

  - ### updateReverse

    protected void updateReverse(List<E> resolved)
    Overrides:
      `updateReverse` in class `RelationshipFault<E>`