To use an IndirectSet:
Implementation notes:
org.eclipse.persistence.mappings.CollectionMapping
| Modifier and Type | Field and Description |
|---|---|
| private transient Set | addedElements
Store added elements to avoid instantiation on add. |
| private transient String | attributeName
The mapping attribute name, used to raise change events. |
| private transient PropertyChangeListener | changeListener
Change tracking listener. |
| private volatile Set | delegate
Reduce type casting |
| protected int | initialCapacity
Store initial size for lazy init. |
| protected float | loadFactor
Store load factor for lazy init. |
| private transient Set | removedElements
Store removed elements to avoid instantiation on remove. |
| private boolean | useLazyInstantiation
This value is used to determine if we should attempt to do adds and removes from the list without actually instantiating the list from the database. |
| private volatile ValueHolderInterface | valueHolder
Delegate indirection behavior to a value holder |
| Access | Constructor and Description |
|---|---|
| public | |
| public | IndirectSet(int
the initial capacity of the set initialCapacity)Construct an empty IndirectSet with the specified initial capacity. |
| public | IndirectSet(int
the initial capacity of the set initialCapacity, float the load factor of the set loadFactor)Construct an empty IndirectSet with the specified initial capacity and load factor. |
| public | IndirectSet(Collection<? extends E>
the initial elements of the set c)Construct an IndirectSet containing the elements of the specified collection. |
| Modifier and Type | Method and Description |
|---|---|
| public PropertyChangeListener | _persistence_getPropertyChangeListener()
Implements org. |
| public void | _persistence_setPropertyChangeListener(PropertyChangeListener changeListener)
Implements org. |
| public boolean | add(E
element to be added to this set element)Implements java. |
| public boolean | addAll(Collection<? extends E>
collection containing elements to be added to this set c)Implements java. |
| protected Set | |
| public void | clear()
Implements java. |
| public void | clearDeferredChanges()
Implements org. |
| public Object | |
| protected Set | |
| public boolean | contains(Object
element whose presence in this set is to be tested element)Implements java. true if this set contains the specified element.
|
| public boolean | containsAll(Collection<?>
collection to be checked for containment in this set c)Implements java. true if this set contains all of the elements of the
specified collection.
|
| public boolean | equals(Object
object to be compared for equality with this set o)Overrides java. Implements java. |
| public void | forEach(Consumer<? super E>
The action to be performed for each element action)Overrides default java. Iterable
until all elements have been processed or the action throws an
exception.
|
| public Collection | getAddedElements()
Implements org. |
| protected Set | |
| public Set | getDelegateObject()
Implements org. |
| public Collection | getRemovedElements()
Implements org. |
| public String | getTrackedAttributeName()
Implements org. |
| public ValueHolderInterface | getValueHolder()
Implements org. |
| public boolean | |
| public boolean | |
| public boolean | hasDeferredChanges()
Implements org. |
| public int | hashCode()
Overrides java. Implements java. |
| public boolean | |
| public boolean | hasTrackedPropertyChangeListener()
INTERNAL: Return if the collection has a property change listener for change tracking. |
| public boolean | |
| public boolean | isInstantiated()
Implements org. |
| protected boolean | |
| public Iterator | |
| public Stream | parallelStream()
Overrides default java. Stream with this collection as its
source.
|
| protected void | |
| protected void | |
| public boolean | remove(Object
object to be removed from this set, if present element)Implements java. |
| public boolean | removeAll(Collection<?>
collection containing elements to be removed from this set c)Implements java. |
| public boolean | removeIf(Predicate<? super E>
a predicate which returns filter)true for elements to be
removedOverrides default java. |
| public boolean | retainAll(Collection<?>
collection containing elements to be retained in this set c)Implements java. |
| public void | setTrackedAttributeName(String attributeName)
Implements org. |
| public void | setUseLazyInstantiation(boolean useLazyInstantiation)
Implements org. |
| public void | setValueHolder(ValueHolderInterface<Set<E>> valueHolder)
Implements org. |
| protected boolean | |
| protected boolean | shouldUseLazyInstantiation()
Return whether this collection should attempt do deal with adds and removes without retrieving the collection from the dB |
| public int | |
| public Spliterator | spliterator()
Overrides default java. Spliterator over the elements in this set.
|
| public Stream | stream()
Overrides default java. Stream with this collection as its source.
|
| public Object[] | toArray()
Implements java. |
| public <T> T[] | toArray(T[]
the array into which the elements of this set are to be
stored, if it is big enough; otherwise, a new array of the same
runtime type is allocated for this purpose. a)Implements java. |
| public String | toString()
Overrides java. |
| addedElements | back to summary |
|---|---|
| private transient Set<E> addedElements Store added elements to avoid instantiation on add. | |
| attributeName | back to summary |
|---|---|
| private transient String attributeName The mapping attribute name, used to raise change events. | |
| changeListener | back to summary |
|---|---|
| private transient PropertyChangeListener changeListener Change tracking listener. | |
| delegate | back to summary |
|---|---|
| private volatile Set<E> delegate Reduce type casting | |
| initialCapacity | back to summary |
|---|---|
| protected int initialCapacity Store initial size for lazy init. | |
| loadFactor | back to summary |
|---|---|
| protected float loadFactor Store load factor for lazy init. | |
| removedElements | back to summary |
|---|---|
| private transient Set<E> removedElements Store removed elements to avoid instantiation on remove. | |
| useLazyInstantiation | back to summary |
|---|---|
| private boolean useLazyInstantiation This value is used to determine if we should attempt to do adds and removes from the list without actually instantiating the list from the database. By default, this is set to false. When set to true, adding duplicate elements to the set will result in the element being added when the transaction is committed. | |
| valueHolder | back to summary |
|---|---|
| private volatile ValueHolderInterface<Set<E>> valueHolder Delegate indirection behavior to a value holder | |
| IndirectSet | back to summary |
|---|---|
| public IndirectSet() Construct an empty IndirectSet. | |
| IndirectSet | back to summary |
|---|---|
| public IndirectSet(int initialCapacity) Construct an empty IndirectSet with the specified initial capacity.
| |
| IndirectSet | back to summary |
|---|---|
| public IndirectSet(int initialCapacity, float loadFactor) Construct an empty IndirectSet with the specified initial capacity and load factor.
| |
| IndirectSet | back to summary |
|---|---|
| public IndirectSet(Collection<? extends E> c) Construct an IndirectSet containing the elements of the specified collection.
| |
| _persistence_getPropertyChangeListener | back to summary |
|---|---|
| public PropertyChangeListener _persistence_getPropertyChangeListener() Implements org. INTERNAL: Return the property change listener for change tracking.
| |
| _persistence_setPropertyChangeListener | back to summary |
|---|---|
| public void _persistence_setPropertyChangeListener(PropertyChangeListener changeListener) Implements org. INTERNAL: Set the property change listener for change tracking.
| |
| add | back to summary |
|---|---|
| public boolean add(E element) Implements java. Doc from java. Adds the specified element to this set if it is not already present
(optional operation). More formally, adds the specified element
The stipulation above does not imply that sets must accept all
elements; sets may refuse to add any particular element, including
| |
| addAll | back to summary |
|---|---|
| public boolean addAll(Collection<? extends E> c) Implements java. Doc from java. Adds all of the elements in the specified collection to this set if
they're not already present (optional operation). If the specified
collection is also a set, the
| |
| buildDelegate | back to summary |
|---|---|
| protected Set INTERNAL: Return the freshly-built delegate. | |
| clear | back to summary |
|---|---|
| public void clear() Implements java. Doc from java. Removes all of the elements from this set (optional operation). The set will be empty after this call returns.
| |
| clearDeferredChanges | back to summary |
|---|---|
| public void clearDeferredChanges() Implements org. INTERNAL: clear any changes that have been deferred to instantiation. Indirect collections with change tracking avoid instantiation on add/remove.
| |
| clone | back to summary |
|---|---|
| public Object clone() Overrides java. Doc from java. Creates and returns a copy of this object. The precise meaning
of "copy" may depend on the class of the object. The general
intent is that, for any object will be true, and that the expression:x.clone() != x will bex.clone().getClass() == x.getClass() true, but these are not absolute requirements.
While it is typically the case that:
will bex.clone().equals(x) true, this is not an absolute requirement.
By convention, the returned object should be obtained by calling
By convention, the object returned by this method should be independent
of this object (which is being cloned). To achieve this independence,
it may be necessary to modify one or more fields of the object returned
by
| |
| cloneDelegate | back to summary |
|---|---|
| protected Set INTERNAL: Clone the delegate. | |
| contains | back to summary |
|---|---|
| public boolean contains(Object element) Implements java. Doc from java. Returns
| |
| containsAll | back to summary |
|---|---|
| public boolean containsAll(Collection<?> c) Implements java. Doc from java. Returns
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Implements java. Doc from java. Compares the specified object with this set for equality. Returns
| |
| forEach | back to summary |
|---|---|
| public void forEach(Consumer<? super E> action) Overrides default java. Doc from java. Performs the given action for each element of the The behavior of this method is unspecified if the action performs side-effects that modify the underlying source of elements, unless an overriding class has specified a concurrent modification policy. | |
| getAddedElements | back to summary |
|---|---|
| public Collection Implements org. INTERNAL: Return the elements that have been added before instantiation.
| |
| getDelegate | back to summary |
|---|---|
| protected Set INTERNAL: Check whether the contents have been read from the database. If they have not, read them and set the delegate. | |
| getDelegateObject | back to summary |
|---|---|
| public Set Implements org. INTERNAL: Return the real collection object. This will force instantiation.
| |
| getRemovedElements | back to summary |
|---|---|
| public Collection Implements org. INTERNAL: Return the elements that have been removed before instantiation.
| |
| getTrackedAttributeName | back to summary |
|---|---|
| public String getTrackedAttributeName() Implements org. INTERNAL: Return the mapping attribute name, used to raise change events.
| |
| getValueHolder | back to summary |
|---|---|
| public ValueHolderInterface Implements org. INTERNAL: Return the valueHolder.
| |
| hasAddedElements | back to summary |
|---|---|
| public boolean hasAddedElements() INTERNAL: Return if any elements that have been added before instantiation. | |
| hasBeenRegistered | back to summary |
|---|---|
| public boolean hasBeenRegistered() INTERNAL: Return whether this IndirectSet has been registered in a UnitOfWork | |
| hasDeferredChanges | back to summary |
|---|---|
| public boolean hasDeferredChanges() Implements org. INTERNAL: Return if any elements that have been added or removed before instantiation.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Doc from java. Returns the hash code value for this set. The hash code of a set is
defined to be the sum of the hash codes of the elements in the set,
where the hash code of a
| |
| hasRemovedElements | back to summary |
|---|---|
| public boolean hasRemovedElements() INTERNAL: Return if any elements that have been removed before instantiation. | |
| hasTrackedPropertyChangeListener | back to summary |
|---|---|
| public boolean hasTrackedPropertyChangeListener() INTERNAL: Return if the collection has a property change listener for change tracking. | |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Implements java. Doc from java. Returns
| |
| isInstantiated | back to summary |
|---|---|
| public boolean isInstantiated() Implements org. Return whether the contents have been read from the database.
| |
| isRelationshipMaintenanceRequired | back to summary |
|---|---|
| protected boolean isRelationshipMaintenanceRequired() | |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Doc from java. Returns an iterator over the elements in this set. The elements are returned in no particular order (unless this set is an instance of some class that provides a guarantee).
| |
| parallelStream | back to summary |
|---|---|
| public Stream Overrides default java. Doc from java. Returns a possibly parallel This method should be overridden when the | |
| raiseAddChangeEvent | back to summary |
|---|---|
| protected void raiseAddChangeEvent(Object element) Raise the add change event and relationship maintainence. | |
| raiseRemoveChangeEvent | back to summary |
|---|---|
| protected void raiseRemoveChangeEvent(Object element) Raise the remove change event. | |
| remove | back to summary |
|---|---|
| public boolean remove(Object element) Implements java. Doc from java. Removes the specified element from this set if it is present
(optional operation). More formally, removes an element
| |
| removeAll | back to summary |
|---|---|
| public boolean removeAll(Collection<?> c) Implements java. Doc from java. Removes from this set all of its elements that are contained in the specified collection (optional operation). If the specified collection is also a set, this operation effectively modifies this set so that its value is the asymmetric set difference of the two sets.
| |
| removeIf | back to summary |
|---|---|
| public boolean removeIf(Predicate<? super E> filter) Overrides default java. Doc from java. Removes all of the elements of this collection that satisfy the given predicate. Errors or runtime exceptions thrown during iteration or by the predicate are relayed to the caller. | |
| retainAll | back to summary |
|---|---|
| public boolean retainAll(Collection<?> c) Implements java. Doc from java. Retains only the elements in this set that are contained in the specified collection (optional operation). In other words, removes from this set all of its elements that are not contained in the specified collection. If the specified collection is also a set, this operation effectively modifies this set so that its value is the intersection of the two sets.
| |
| setTrackedAttributeName | back to summary |
|---|---|
| public void setTrackedAttributeName(String attributeName) Implements org. INTERNAL: Set the mapping attribute name, used to raise change events. This is required if the change listener is set.
| |
| setUseLazyInstantiation | back to summary |
|---|---|
| public void setUseLazyInstantiation(boolean useLazyInstantiation) Implements org. INTERNAL Set whether this collection should attempt do deal with adds and removes without retrieving the collection from the dB
| |
| setValueHolder | back to summary |
|---|---|
| public void setValueHolder(ValueHolderInterface<Set<E>> valueHolder) Implements org. INTERNAL: Set the value holder. Note that the delegate must be cleared out.
| |
| shouldAvoidInstantiation | back to summary |
|---|---|
| protected boolean shouldAvoidInstantiation() INTERNAL: Return if add/remove should trigger instantiation or avoid. Current instantiation is avoided is using change tracking. | |
| shouldUseLazyInstantiation | back to summary |
|---|---|
| protected boolean shouldUseLazyInstantiation() Return whether this collection should attempt do deal with adds and removes without retrieving the collection from the dB | |
| size | back to summary |
|---|---|
| public int size() Implements java. Doc from java. Returns the number of elements in this set (its cardinality). If this
set contains more than
| |
| spliterator | back to summary |
|---|---|
| public Spliterator Overrides default java. Doc from java. Creates a The
| |
| stream | back to summary |
|---|---|
| public Stream Overrides default java. Doc from java. Returns a sequential This method should be overridden when the | |
| toArray | back to summary |
|---|---|
| public Object[] toArray() Implements java. Doc from java. Returns an array containing all of the elements in this set. If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order. The returned array will be "safe" in that no references to it are maintained by this set. (In other words, this method must allocate a new array even if this set is backed by an array). The caller is thus free to modify the returned array. This method acts as bridge between array-based and collection-based APIs.
| |
| toArray | back to summary |
|---|---|
| public <T> T[] toArray(T[] a) Implements java. Doc from java. Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array. If the set fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this set. If this set fits in the specified array with room to spare
(i.e., the array has more elements than this set), the element in
the array immediately following the end of the set is set to
If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order. Like the Suppose
String[] y = x.toArray(new String[0]);
Note that toArray(new Object[0]) is identical in function to
toArray().
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Use the delegate's #toString(); but wrap it with braces to indicate there is a bit of indirection. Don't allow this method to trigger a database read.
| |