org.apache.cayenne.util

## Class PersistentObjectSet

- java.lang.Object
- - org.apache.cayenne.util.RelationshipFault
  - - org.apache.cayenne.util.PersistentObjectSet

- All Implemented Interfaces:
    Serializable, Iterable, Collection, Set, PersistentObjectCollection, ValueHolder
  Direct Known Subclasses:
    ToManySet

      public class PersistentObjectSet
      extends RelationshipFault
      implements Set, ValueHolder, PersistentObjectCollection

  Since:
    3.0
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Set` | `addedToUnresolved`
    `protected Set` | `objectSet`
    `protected Set` | `removedFromUnresolved`

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

      `relationshipName, relationshipOwner`

  - ### Constructor Summary

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

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `add(Object o)`
    `boolean` | `addAll(Collection c)`
    `void` | `addDirectly(Object target)` Adds an object without triggering an event
    `void` | `clear()`
    `boolean` | `contains(Object o)`
    `boolean` | `containsAll(Collection c)`
    `boolean` | `equals(Object o)`
    `Object` | `getValue()` Returns an object stored by this ValueHolder.
    `Object` | `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` | `iterator()`
    `protected void` | `mergeLocalChanges(List resolved)`
    `protected void` | `postprocessAdd(Collection<?> collection)`
    `protected void` | `postprocessAdd(Object addedObject)`
    `protected void` | `postprocessRemove(Collection<?> collection)`
    `protected void` | `postprocessRemove(Object removedObject)`
    `boolean` | `remove(Object o)`
    `boolean` | `removeAll(Collection c)`
    `void` | `removeDirectly(Object target)` Removes an object without triggering an event
    `protected Set` | `resolvedObjectSet()` Returns internal objects list resolving it if needed.
    `boolean` | `retainAll(Collection c)`
    `void` | `setObjectSet(Set 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(Object object)`
    `int` | `size()`
    `Object[]` | `toArray()`
    `Object[]` | `toArray(Object[] 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.Set

      `spliterator`

    - ### Methods inherited from interface java.util.Collection

      `parallelStream, removeIf, stream`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach`

- - ### Field Detail

    - #### objectSet

          protected Set objectSet

    - #### addedToUnresolved

          protected Set addedToUnresolved

    - #### removedFromUnresolved

          protected Set removedFromUnresolved

  - ### Constructor Detail

    - #### PersistentObjectSet

          public PersistentObjectSet(Persistent relationshipOwner,
                                     String relationshipName)

  - ### Method Detail

    - #### isFault

          public boolean isFault()

      Returns whether this list is not yet resolved and requires a fetch.
      Specified by:
        `isFault` in interface `ValueHolder`

    - #### invalidate

          public void invalidate()

      Turns itself into a fault, thus forcing a refresh on the next access.
      Specified by:
        `invalidate` in interface `ValueHolder`

    - #### 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`
      Throws:
        `CayenneRuntimeException`

    - #### getValue

          public Object getValue()
                          throws CayenneRuntimeException

      Description copied from interface: `ValueHolder`
      Returns an object stored by this ValueHolder.
      Specified by:
        `getValue` in interface `ValueHolder`
      Throws:
        `CayenneRuntimeException`

    - #### getValueDirectly

          public Object getValueDirectly()
                                  throws CayenneRuntimeException

      Description copied from interface: `ValueHolder`
      Retrieves ValueHolder value without triggering fault resolution.
      Specified by:
        `getValueDirectly` in interface `ValueHolder`
      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`
      Parameters:
        `value` - a new value of the ValueHolder.
      Returns:
        a previous value saved in the ValueHolder.
      Throws:
        `CayenneRuntimeException`

    - #### setObjectSet

          public void setObjectSet(Set objectSet)

    - #### shouldAddToRemovedFromUnresolvedSet

          protected boolean shouldAddToRemovedFromUnresolvedSet(Object object)

    - #### add

          public boolean add(Object o)

      Specified by:
        `add` in interface `Collection`
      Specified by:
        `add` in interface `Set`

    - #### addAll

          public boolean addAll(Collection c)

      Specified by:
        `addAll` in interface `Collection`
      Specified by:
        `addAll` in interface `Set`

    - #### clear

          public void clear()

      Specified by:
        `clear` in interface `Collection`
      Specified by:
        `clear` in interface `Set`

    - #### contains

          public boolean contains(Object o)

      Specified by:
        `contains` in interface `Collection`
      Specified by:
        `contains` in interface `Set`

    - #### containsAll

          public boolean containsAll(Collection c)

      Specified by:
        `containsAll` in interface `Collection`
      Specified by:
        `containsAll` in interface `Set`

    - #### equals

          public boolean equals(Object o)

      Specified by:
        `equals` in interface `Collection`
      Specified by:
        `equals` in interface `Set`
      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Specified by:
        `hashCode` in interface `Collection`
      Specified by:
        `hashCode` in interface `Set`
      Overrides:
        `hashCode` in class `Object`

    - #### isEmpty

          public boolean isEmpty()

      Specified by:
        `isEmpty` in interface `Collection`
      Specified by:
        `isEmpty` in interface `Set`

    - #### iterator

          public Iterator iterator()

      Specified by:
        `iterator` in interface `Iterable`
      Specified by:
        `iterator` in interface `Collection`
      Specified by:
        `iterator` in interface `Set`

    - #### remove

          public boolean remove(Object o)

      Specified by:
        `remove` in interface `Collection`
      Specified by:
        `remove` in interface `Set`

    - #### removeAll

          public boolean removeAll(Collection c)

      Specified by:
        `removeAll` in interface `Collection`
      Specified by:
        `removeAll` in interface `Set`

    - #### retainAll

          public boolean retainAll(Collection c)

      Specified by:
        `retainAll` in interface `Collection`
      Specified by:
        `retainAll` in interface `Set`

    - #### size

          public int size()

      Specified by:
        `size` in interface `Collection`
      Specified by:
        `size` in interface `Set`

    - #### toArray

          public Object[] toArray()

      Specified by:
        `toArray` in interface `Collection`
      Specified by:
        `toArray` in interface `Set`

    - #### toArray

          public Object[] toArray(Object[] a)

      Specified by:
        `toArray` in interface `Collection`
      Specified by:
        `toArray` in interface `Set`

    - #### resolvedObjectSet

          protected Set resolvedObjectSet()

      Returns internal objects list resolving it if needed.

    - #### mergeLocalChanges

          protected void mergeLocalChanges(List resolved)

      Specified by:
        `mergeLocalChanges` in class `RelationshipFault`

    - #### postprocessAdd

          protected void postprocessAdd(Collection<?> collection)

    - #### postprocessRemove

          protected void postprocessRemove(Collection<?> collection)

    - #### postprocessAdd

          protected void postprocessAdd(Object addedObject)

    - #### postprocessRemove

          protected void postprocessRemove(Object removedObject)

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### addDirectly

          public void addDirectly(Object target)

      Description copied from interface: `PersistentObjectCollection`
      Adds an object without triggering an event
      Specified by:
        `addDirectly` in interface `PersistentObjectCollection`

    - #### removeDirectly

          public void removeDirectly(Object target)

      Description copied from interface: `PersistentObjectCollection`
      Removes an object without triggering an event
      Specified by:
        `removeDirectly` in interface `PersistentObjectCollection`

Copyright © 2001–2023 Apache Cayenne. All rights reserved.