Package org.apache.cayenne.util

# Class PersistentObjectSet<E>

java.lang.Object
org.apache.cayenne.util.RelationshipFault<E>
org.apache.cayenne.util.PersistentObjectSet<E>

All Implemented Interfaces:
  `Serializable`, `Iterable<E>`, `Collection<E>`, `Set<E>`, `PersistentObjectCollection<E>`, `ValueHolder<Object>`

Direct Known Subclasses:
  `ToManySet`

public class PersistentObjectSet<E> extends RelationshipFault<E> implements Set<E>, ValueHolder<Object>, PersistentObjectCollection<E>

Since:
  3.0
See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected Set<E>`
  `addedToUnresolved`
  `protected Set<E>`
  `objectSet`
  `protected Set<E>`
  `removedFromUnresolved`

  ### Fields inherited from class org.apache.cayenne.util.RelationshipFault

  `relationshipName, relationshipOwner`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PersistentObjectSet(Persistent relationshipOwner, String relationshipName)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `add(E o)`
  `boolean`
  `addAll(Collection<? extends E> c)`
  `void`
  `addDirectly(E target)`
  Adds an object without triggering an event
  `void`
  `clear()`
  `boolean`
  `contains(Object o)`
  `boolean`
  `containsAll(Collection c)`
  `boolean`
  `equals(Object o)`
  `Set<E>`
  `getValue()`
  Returns an object stored by this ValueHolder.
  `Set<E>`
  `getValueDirectly()`
  Retrieves ValueHolder value without triggering fault resolution.
  `int`
  `hashCode()`
  `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()`
  `protected void`
  `mergeLocalChanges(List<E> resolved)`
  `protected void`
  `postprocessAdd(E addedObject)`
  `protected void`
  `postprocessAdd(Collection<? extends E> collection)`
  `protected void`
  `postprocessRemove(E removedObject)`
  `protected void`
  `postprocessRemove(Collection<? extends E> collection)`
  `boolean`
  `remove(Object o)`
  `boolean`
  `removeAll(Collection<?> c)`
  `void`
  `removeDirectly(E target)`
  Removes an object without triggering an event
  `protected Set<E>`
  `resolvedObjectSet()`
  Returns internal objects list resolving it if needed.
  `boolean`
  `retainAll(Collection<?> c)`
  `void`
  `setObjectSet(Set<E> objectSet)`
  `Object`
  `setValue(Object value)`
  Sets an object stored by this ValueHolder.
  `Object`
  `setValueDirectly(Object value)`
  Sets ValueHolder vaue without triggering fault resolution.
  `protected boolean`
  `shouldAddToRemovedFromUnresolvedSet(E object)`
  `int`
  `size()`
  `Object[]`
  `toArray()`
  `<T> T[]`
  `toArray(T[] a)`
  `String`
  `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.lang.Iterable

  `forEach`

  ### Methods inherited from interface java.util.Set

  `spliterator`

- ## Field Details

  - ### objectSet

    protected Set<E> objectSet

  - ### addedToUnresolved

    protected Set<E> addedToUnresolved

  - ### removedFromUnresolved

    protected Set<E> removedFromUnresolved

- ## Constructor Details

  - ### PersistentObjectSet

    public PersistentObjectSet(Persistent relationshipOwner, String relationshipName)

- ## Method Details

  - ### isFault

    public boolean isFault()
    Returns whether this list is not yet resolved and requires a fetch.
    Specified by:
      `isFault` in interface `ValueHolder<E>`

  - ### invalidate

    public void invalidate()
    Turns itself into a fault, thus forcing a refresh on the next access.
    Specified by:
      `invalidate` in interface `ValueHolder<E>`

  - ### setValueDirectly

    public Object setValueDirectly(Object value) throws CayenneRuntimeException
    Description copied from interface: `ValueHolder`
    Sets ValueHolder vaue without triggering fault resolution.
    Specified by:
      `setValueDirectly` in interface `ValueHolder<E>`
    Throws:
      `CayenneRuntimeException`

  - ### getValue

    public Set<E> getValue() throws CayenneRuntimeException
    Description copied from interface: `ValueHolder`
    Returns an object stored by this ValueHolder.
    Specified by:
      `getValue` in interface `ValueHolder<E>`
    Throws:
      `CayenneRuntimeException`

  - ### getValueDirectly

    public Set<E> getValueDirectly() throws CayenneRuntimeException
    Description copied from interface: `ValueHolder`
    Retrieves ValueHolder value without triggering fault resolution.
    Specified by:
      `getValueDirectly` in interface `ValueHolder<E>`
    Throws:
      `CayenneRuntimeException`

  - ### setValue

    public Object setValue(Object value) throws CayenneRuntimeException
    Description copied from interface: `ValueHolder`
    Sets an object stored by this ValueHolder.
    Specified by:
      `setValue` in interface `ValueHolder<E>`
    Parameters:
      `value` - a new value of the ValueHolder.
    Returns:
      a previous value saved in the ValueHolder.
    Throws:
      `CayenneRuntimeException`

  - ### setObjectSet

    public void setObjectSet(Set<E> objectSet)

  - ### add

    public boolean add(E o)
    Specified by:
      `add` in interface `Collection<E>`
    Specified by:
      `add` in interface `Set<E>`

  - ### addAll

    public boolean addAll(Collection<? extends E> c)
    Specified by:
      `addAll` in interface `Collection<E>`
    Specified by:
      `addAll` in interface `Set<E>`

  - ### clear

    public void clear()
    Specified by:
      `clear` in interface `Collection<E>`
    Specified by:
      `clear` in interface `Set<E>`

  - ### contains

    public boolean contains(Object o)
    Specified by:
      `contains` in interface `Collection<E>`
    Specified by:
      `contains` in interface `Set<E>`

  - ### containsAll

    public boolean containsAll(Collection c)
    Specified by:
      `containsAll` in interface `Collection<E>`
    Specified by:
      `containsAll` in interface `Set<E>`

  - ### equals

    public boolean equals(Object o)
    Specified by:
      `equals` in interface `Collection<E>`
    Specified by:
      `equals` in interface `Set<E>`
    Overrides:
      `equals` in class `Object`

  - ### hashCode

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

  - ### isEmpty

    public boolean isEmpty()
    Specified by:
      `isEmpty` in interface `Collection<E>`
    Specified by:
      `isEmpty` in interface `Set<E>`

  - ### iterator

    public Iterator<E> iterator()
    Specified by:
      `iterator` in interface `Collection<E>`
    Specified by:
      `iterator` in interface `Iterable<E>`
    Specified by:
      `iterator` in interface `Set<E>`

  - ### remove

    public boolean remove(Object o)
    Specified by:
      `remove` in interface `Collection<E>`
    Specified by:
      `remove` in interface `Set<E>`

  - ### removeAll

    public boolean removeAll(Collection<?> c)
    Specified by:
      `removeAll` in interface `Collection<E>`
    Specified by:
      `removeAll` in interface `Set<E>`

  - ### retainAll

    public boolean retainAll(Collection<?> c)
    Specified by:
      `retainAll` in interface `Collection<E>`
    Specified by:
      `retainAll` in interface `Set<E>`

  - ### size

    public int size()
    Specified by:
      `size` in interface `Collection<E>`
    Specified by:
      `size` in interface `Set<E>`

  - ### toArray

    public Object[] toArray()
    Specified by:
      `toArray` in interface `Collection<E>`
    Specified by:
      `toArray` in interface `Set<E>`

  - ### toArray

    public <T> T[] toArray(T[] a)
    Specified by:
      `toArray` in interface `Collection<E>`
    Specified by:
      `toArray` in interface `Set<E>`

  - ### resolvedObjectSet

    protected Set<E> resolvedObjectSet()
    Returns internal objects list resolving it if needed.

  - ### mergeLocalChanges

    protected void mergeLocalChanges(List<E> resolved)
    Specified by:
      `mergeLocalChanges` in class `RelationshipFault<E>`

  - ### 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)

  - ### shouldAddToRemovedFromUnresolvedSet

    protected boolean shouldAddToRemovedFromUnresolvedSet(E object)

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### addDirectly

    public void addDirectly(E target)
    Description copied from interface: `PersistentObjectCollection`
    Adds an object without triggering an event
    Specified by:
      `addDirectly` in interface `PersistentObjectCollection<E>`

  - ### removeDirectly

    public void removeDirectly(E target)
    Description copied from interface: `PersistentObjectCollection`
    Removes an object without triggering an event
    Specified by:
      `removeDirectly` in interface `PersistentObjectCollection<E>`