Top Description Fields Constructors Methods
org.eclipse.persistence.indirection

public Class IndirectSet<E>

extends Object
implements CollectionChangeTracker, Set<E>, IndirectCollection<E, Set<E>>, Cloneable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Cloneable, org.eclipse.persistence.indirection.IndirectCollection, org.eclipse.persistence.indirection.IndirectContainer, java.util.Set, java.util.Collection, java.lang.Iterable, org.eclipse.persistence.descriptors.changetracking.CollectionChangeTracker, org.eclipse.persistence.descriptors.changetracking.ChangeTracker
Type Parameters
<E>
the type of elements maintained by this set
Imports
java.beans.PropertyChangeListener, java.io.Serializable, java.lang.reflect.InvocationTargetException, .Method, java.util.Collection, .HashSet, .Iterator, .Set, .Spliterator, java.util.function.Consumer, .Predicate, java.util.stream.Stream, org.eclipse.persistence.descriptors.changetracking.CollectionChangeEvent, .CollectionChangeTracker, org.eclipse.persistence.exceptions.QueryException, org.eclipse.persistence.internal.descriptors.changetracking.AttributeChangeListener, org.eclipse.persistence.internal.indirection.UnitOfWorkQueryValueHolder, org.eclipse.persistence.internal.localization.ToStringLocalization, org.eclipse.persistence.internal.security.PrivilegedAccessHelper, org.eclipse.persistence.mappings.DatabaseMapping

IndirectSet is an example implementation of the Set protocol that allows a domain class to take advantage of TopLink Indirection without having to declare its instance variable as a ValueHolderInterface.

To use an IndirectSet:

TopLink will place an IndirectSet in the instance variable when the containing domain object is read from the database. With the first message sent to the IndirectSet, the contents are fetched from the database and normal Set behavior is resumed.

Implementation notes:

Author
Big Country
Since
TOPLink/Java 3.0+
See Also
org.eclipse.persistence.mappings.CollectionMapping

Field Summary

Modifier and TypeField and Description
private transient Set<E>
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<E>
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<E>
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<Set<E>>
valueHolder

Delegate indirection behavior to a value holder

Constructor Summary

AccessConstructor and Description
public
IndirectSet()

Construct an empty IndirectSet.

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.

Method Summary

Modifier and TypeMethod and Description
public PropertyChangeListener
public void
public boolean
add(E
element to be added to this set
element
)

Implements java.util.Set.add.

Adds the specified element to this set if it is not already present (optional operation).
public boolean
addAll(Collection<? extends E>
collection containing elements to be added to this set
c
)

Implements java.util.Set.addAll.

Adds all of the elements in the specified collection to this set if they're not already present (optional operation).
protected Set<E>
buildDelegate()

INTERNAL: Return the freshly-built delegate.

public void
clear()

Implements java.util.Set.clear.

Removes all of the elements from this set (optional operation).
public void
clearDeferredChanges()

Implements org.eclipse.persistence.indirection.IndirectCollection.clearDeferredChanges.

INTERNAL: clear any changes that have been deferred to instantiation.
public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
protected Set<E>
cloneDelegate()

INTERNAL: Clone the delegate.

public boolean
contains(Object
element whose presence in this set is to be tested
element
)

Implements java.util.Set.contains.

Returns true if this set contains the specified element.
public boolean
containsAll(Collection<?>
collection to be checked for containment in this set
c
)

Implements java.util.Set.containsAll.

Returns 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.lang.Object.equals.

Implements java.util.Set.equals.

Compares the specified object with this set for equality.
public void
forEach(Consumer<? super E>
The action to be performed for each element
action
)

Overrides default java.lang.Iterable.forEach.

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.
public Collection<E>
getAddedElements()

Implements org.eclipse.persistence.indirection.IndirectCollection.getAddedElements.

INTERNAL: Return the elements that have been added before instantiation.
protected Set<E>
getDelegate()

INTERNAL: Check whether the contents have been read from the database.

public Set<E>
getDelegateObject()

Implements org.eclipse.persistence.indirection.IndirectCollection.getDelegateObject.

INTERNAL: Return the real collection object.
public Collection<E>
getRemovedElements()

Implements org.eclipse.persistence.indirection.IndirectCollection.getRemovedElements.

INTERNAL: Return the elements that have been removed before instantiation.
public String
getTrackedAttributeName()

Implements org.eclipse.persistence.descriptors.changetracking.CollectionChangeTracker.getTrackedAttributeName.

INTERNAL: Return the mapping attribute name, used to raise change events.
public ValueHolderInterface<Set<E>>
public boolean
hasAddedElements()

INTERNAL: Return if any elements that have been added before instantiation.

public boolean
hasBeenRegistered()

INTERNAL: Return whether this IndirectSet has been registered in a UnitOfWork

public boolean
hasDeferredChanges()

Implements org.eclipse.persistence.indirection.IndirectCollection.hasDeferredChanges.

INTERNAL: Return if any elements that have been added or removed before instantiation.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.Set.hashCode.

Returns the hash code value for this set.
public boolean
hasRemovedElements()

INTERNAL: Return if any elements that have been removed before instantiation.

public boolean
hasTrackedPropertyChangeListener()

INTERNAL: Return if the collection has a property change listener for change tracking.

public boolean
isEmpty()

Implements java.util.Set.isEmpty.

Returns true if this set contains no elements.
public boolean
isInstantiated()

Implements org.eclipse.persistence.indirection.IndirectContainer.isInstantiated.

Return whether the contents have been read from the database.
protected boolean
public Iterator<E>
iterator()

Implements java.util.Set.iterator.

Returns an iterator over the elements in this set.
public Stream<E>
parallelStream()

Overrides default java.util.Collection.parallelStream.

Returns a possibly parallel Stream with this collection as its source.
protected void
raiseAddChangeEvent(Object element)

Raise the add change event and relationship maintainence.

protected void
raiseRemoveChangeEvent(Object element)

Raise the remove change event.

public boolean
remove(Object
object to be removed from this set, if present
element
)

Implements java.util.Set.remove.

Removes the specified element from this set if it is present (optional operation).
public boolean
removeAll(Collection<?>
collection containing elements to be removed from this set
c
)

Implements java.util.Set.removeAll.

Removes from this set all of its elements that are contained in the specified collection (optional operation).
public boolean
removeIf(Predicate<? super E>
a predicate which returns true for elements to be removed
filter
)

Overrides default java.util.Collection.removeIf.

Removes all of the elements of this collection that satisfy the given predicate.
public boolean
retainAll(Collection<?>
collection containing elements to be retained in this set
c
)

Implements java.util.Set.retainAll.

Retains only the elements in this set that are contained in the specified collection (optional operation).
public void
setTrackedAttributeName(String attributeName)

Implements org.eclipse.persistence.descriptors.changetracking.CollectionChangeTracker.setTrackedAttributeName.

INTERNAL: Set the mapping attribute name, used to raise change events.
public void
setUseLazyInstantiation(boolean useLazyInstantiation)

Implements org.eclipse.persistence.indirection.IndirectCollection.setUseLazyInstantiation.

INTERNAL Set whether this collection should attempt do deal with adds and removes without retrieving the collection from the dB
public void
protected boolean
shouldAvoidInstantiation()

INTERNAL: Return if add/remove should trigger instantiation or avoid.

protected boolean
shouldUseLazyInstantiation()

Return whether this collection should attempt do deal with adds and removes without retrieving the collection from the dB

public int
size()

Implements java.util.Set.size.

Returns the number of elements in this set (its cardinality).
public Spliterator<E>
spliterator()

Overrides default java.util.Set.spliterator.

Creates a Spliterator over the elements in this set.
public Stream<E>
stream()

Overrides default java.util.Collection.stream.

Returns a sequential Stream with this collection as its source.
public Object[]
toArray()

Implements java.util.Set.toArray.

Returns an array containing all of the elements in this set.
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.util.Set.toArray.

Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.
public String
toString()

Overrides java.lang.Object.toString.

Use the delegate's #toString(); but wrap it with braces to indicate there is a bit of indirection.
Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

addedElementsback to summary
private transient Set<E> addedElements

Store added elements to avoid instantiation on add.

attributeNameback to summary
private transient String attributeName

The mapping attribute name, used to raise change events.

changeListenerback to summary
private transient PropertyChangeListener changeListener

Change tracking listener.

delegateback to summary
private volatile Set<E> delegate

Reduce type casting

initialCapacityback to summary
protected int initialCapacity

Store initial size for lazy init.

loadFactorback to summary
protected float loadFactor

Store load factor for lazy init.

removedElementsback to summary
private transient Set<E> removedElements

Store removed elements to avoid instantiation on remove.

useLazyInstantiationback 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.

valueHolderback to summary
private volatile ValueHolderInterface<Set<E>> valueHolder

Delegate indirection behavior to a value holder

Constructor Detail

IndirectSetback to summary
public IndirectSet()

Construct an empty IndirectSet.

IndirectSetback to summary
public IndirectSet(int initialCapacity)

Construct an empty IndirectSet with the specified initial capacity.

Parameters
initialCapacity:int

the initial capacity of the set

Exceptions
IllegalArgumentException:
if the specified initial capacity is negative
IndirectSetback to summary
public IndirectSet(int initialCapacity, float loadFactor)

Construct an empty IndirectSet with the specified initial capacity and load factor.

Parameters
initialCapacity:int

the initial capacity of the set

loadFactor:float

the load factor of the set

Exceptions
IllegalArgumentException:
if the specified initial capacity is negative
IndirectSetback to summary
public IndirectSet(Collection<? extends E> c)

Construct an IndirectSet containing the elements of the specified collection.

Parameters
c:Collection<? extends E>

the initial elements of the set

Method Detail

_persistence_getPropertyChangeListenerback to summary
public PropertyChangeListener _persistence_getPropertyChangeListener()

Implements org.eclipse.persistence.descriptors.changetracking.ChangeTracker._persistence_getPropertyChangeListener.

INTERNAL: Return the property change listener for change tracking.

Annotations
@Override
_persistence_setPropertyChangeListenerback to summary
public void _persistence_setPropertyChangeListener(PropertyChangeListener changeListener)

Implements org.eclipse.persistence.descriptors.changetracking.ChangeTracker._persistence_setPropertyChangeListener.

INTERNAL: Set the property change listener for change tracking.

Annotations
@Override
addback to summary
public boolean add(E element)

Implements java.util.Set.add.

Doc from java.util.Set.add.

Adds the specified element to this set if it is not already present (optional operation). More formally, adds the specified element e to this set if the set contains no element e2 such that Objects.equals(e, e2). If this set already contains the element, the call leaves the set unchanged and returns false. In combination with the restriction on constructors, this ensures that sets never contain duplicate elements.

The stipulation above does not imply that sets must accept all elements; sets may refuse to add any particular element, including null, and throw an exception, as described in the specification for Collection.add. Individual set implementations should clearly document any restrictions on the elements that they may contain.

Parameters
element:E

element to be added to this set

Returns:boolean

true if this set did not already contain the specified element

Annotations
@Override
See Also
java.util.Set#add(java.lang.Object)
addAllback to summary
public boolean addAll(Collection<? extends E> c)

Implements java.util.Set.addAll.

Doc from java.util.Set.addAll.

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 addAll operation effectively modifies this set so that its value is the union of the two sets. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress.

Parameters
c:Collection<? extends E>

collection containing elements to be added to this set

Returns:boolean

true if this set changed as a result of the call

Annotations
@Override
See Also
java.util.Set#addAll(java.util.Collection)
buildDelegateback to summary
protected Set<E> buildDelegate()

INTERNAL: Return the freshly-built delegate.

clearback to summary
public void clear()

Implements java.util.Set.clear.

Doc from java.util.Set.clear.

Removes all of the elements from this set (optional operation). The set will be empty after this call returns.

Annotations
@Override
See Also
java.util.Set#clear()
clearDeferredChangesback to summary
public void clearDeferredChanges()

Implements org.eclipse.persistence.indirection.IndirectCollection.clearDeferredChanges.

INTERNAL: clear any changes that have been deferred to instantiation. Indirect collections with change tracking avoid instantiation on add/remove.

Annotations
@Override
cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

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 x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

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 super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a clone of this instance.

Annotations
@Override
See Also
This will result in a database query if necessary.
cloneDelegateback to summary
protected Set<E> cloneDelegate()

INTERNAL: Clone the delegate.

containsback to summary
public boolean contains(Object element)

Implements java.util.Set.contains.

Doc from java.util.Set.contains.

Returns true if this set contains the specified element. More formally, returns true if and only if this set contains an element e such that Objects.equals(o, e).

Parameters
element:Object

element whose presence in this set is to be tested

Returns:boolean

true if this set contains the specified element

Annotations
@Override
See Also
java.util.Set#contains(java.lang.Object)
containsAllback to summary
public boolean containsAll(Collection<?> c)

Implements java.util.Set.containsAll.

Doc from java.util.Set.containsAll.

Returns true if this set contains all of the elements of the specified collection. If the specified collection is also a set, this method returns true if it is a subset of this set.

Parameters
c:Collection<?>

collection to be checked for containment in this set

Returns:boolean

true if this set contains all of the elements of the specified collection

Annotations
@Override
See Also
java.util.Set#containsAll(java.util.Collection)
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Implements java.util.Set.equals.

Doc from java.util.Set.equals.

Compares the specified object with this set for equality. Returns true if the specified object is also a set, the two sets have the same size, and every member of the specified set is contained in this set (or equivalently, every member of this set is contained in the specified set). This definition ensures that the equals method works properly across different implementations of the set interface.

Parameters
o:Object

object to be compared for equality with this set

Returns:boolean

true if the specified object is equal to this set

Annotations
@Override
See Also
java.util.Set#equals(java.lang.Object)
forEachback to summary
public void forEach(Consumer<? super E> action)

Overrides default java.lang.Iterable.forEach.

Doc from java.lang.Iterable.forEach.

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception. Actions are performed in the order of iteration, if that order is specified. Exceptions thrown by the action are relayed to the caller.

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.

Parameters
action:Consumer<? super E>

The action to be performed for each element

Annotations
@Override
getAddedElementsback to summary
public Collection<E> getAddedElements()

Implements org.eclipse.persistence.indirection.IndirectCollection.getAddedElements.

INTERNAL: Return the elements that have been added before instantiation.

Annotations
@Override
getDelegateback to summary
protected Set<E> getDelegate()

INTERNAL: Check whether the contents have been read from the database. If they have not, read them and set the delegate.

getDelegateObjectback to summary
public Set<E> getDelegateObject()

Implements org.eclipse.persistence.indirection.IndirectCollection.getDelegateObject.

INTERNAL: Return the real collection object. This will force instantiation.

Annotations
@Override
getRemovedElementsback to summary
public Collection<E> getRemovedElements()

Implements org.eclipse.persistence.indirection.IndirectCollection.getRemovedElements.

INTERNAL: Return the elements that have been removed before instantiation.

Annotations
@Override
getTrackedAttributeNameback to summary
public String getTrackedAttributeName()

Implements org.eclipse.persistence.descriptors.changetracking.CollectionChangeTracker.getTrackedAttributeName.

INTERNAL: Return the mapping attribute name, used to raise change events.

Annotations
@Override
getValueHolderback to summary
public ValueHolderInterface<Set<E>> getValueHolder()

Implements org.eclipse.persistence.indirection.IndirectContainer.getValueHolder.

INTERNAL: Return the valueHolder.

Returns:ValueHolderInterface<Set<E>>

Doc from org.eclipse.persistence.indirection.IndirectContainer.getValueHolder.

org.eclipse.persistence.indirection.ValueHolderInterface A representation of the valueholder * which this container uses

Annotations
@Override
hasAddedElementsback to summary
public boolean hasAddedElements()

INTERNAL: Return if any elements that have been added before instantiation.

hasBeenRegisteredback to summary
public boolean hasBeenRegistered()

INTERNAL: Return whether this IndirectSet has been registered in a UnitOfWork

hasDeferredChangesback to summary
public boolean hasDeferredChanges()

Implements org.eclipse.persistence.indirection.IndirectCollection.hasDeferredChanges.

INTERNAL: Return if any elements that have been added or removed before instantiation.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements java.util.Set.hashCode.

Doc from java.util.Set.hashCode.

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 null element is defined to be zero. This ensures that s1.equals(s2) implies that s1.hashCode()==s2.hashCode() for any two sets s1 and s2, as required by the general contract of Object#hashCode.

Returns:int

the hash code value for this set

Annotations
@Override
See Also
java.util.Set#hashCode()
hasRemovedElementsback to summary
public boolean hasRemovedElements()

INTERNAL: Return if any elements that have been removed before instantiation.

hasTrackedPropertyChangeListenerback to summary
public boolean hasTrackedPropertyChangeListener()

INTERNAL: Return if the collection has a property change listener for change tracking.

isEmptyback to summary
public boolean isEmpty()

Implements java.util.Set.isEmpty.

Doc from java.util.Set.isEmpty.

Returns true if this set contains no elements.

Returns:boolean

true if this set contains no elements

Annotations
@Override
See Also
java.util.Set#isEmpty()
isInstantiatedback to summary
public boolean isInstantiated()

Implements org.eclipse.persistence.indirection.IndirectContainer.isInstantiated.

Return whether the contents have been read from the database.

Annotations
@Override
isRelationshipMaintenanceRequiredback to summary
protected boolean isRelationshipMaintenanceRequired()
iteratorback to summary
public Iterator<E> iterator()

Implements java.util.Set.iterator.

Doc from java.util.Set.iterator.

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

Returns:Iterator<E>

an iterator over the elements in this set

Annotations
@Override
See Also
java.util.Set#iterator()
parallelStreamback to summary
public Stream<E> parallelStream()

Overrides default java.util.Collection.parallelStream.

Doc from java.util.Collection.parallelStream.

Returns a possibly parallel Stream with this collection as its source. It is allowable for this method to return a sequential stream.

This method should be overridden when the spliterator() method cannot return a spliterator that is IMMUTABLE, CONCURRENT, or late-binding. (See spliterator() for details.)

Returns:Stream<E>

a possibly parallel Stream over the elements in this collection

Annotations
@Override
raiseAddChangeEventback to summary
protected void raiseAddChangeEvent(Object element)

Raise the add change event and relationship maintainence.

raiseRemoveChangeEventback to summary
protected void raiseRemoveChangeEvent(Object element)

Raise the remove change event.

removeback to summary
public boolean remove(Object element)

Implements java.util.Set.remove.

Doc from java.util.Set.remove.

Removes the specified element from this set if it is present (optional operation). More formally, removes an element e such that Objects.equals(o, e), if this set contains such an element. Returns true if this set contained the element (or equivalently, if this set changed as a result of the call). (This set will not contain the element once the call returns.)

Parameters
element:Object

object to be removed from this set, if present

Returns:boolean

true if this set contained the specified element

Annotations
@Override
See Also
java.util.Set#remove(java.lang.Object)
removeAllback to summary
public boolean removeAll(Collection<?> c)

Implements java.util.Set.removeAll.

Doc from java.util.Set.removeAll.

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.

Parameters
c:Collection<?>

collection containing elements to be removed from this set

Returns:boolean

true if this set changed as a result of the call

Annotations
@Override
See Also
java.util.Set#removeAll(java.util.Collection)
removeIfback to summary
public boolean removeIf(Predicate<? super E> filter)

Overrides default java.util.Collection.removeIf.

Doc from java.util.Collection.removeIf.

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.

Parameters
filter:Predicate<? super E>

a predicate which returns true for elements to be removed

Returns:boolean

true if any elements were removed

Annotations
@Override
retainAllback to summary
public boolean retainAll(Collection<?> c)

Implements java.util.Set.retainAll.

Doc from java.util.Set.retainAll.

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.

Parameters
c:Collection<?>

collection containing elements to be retained in this set

Returns:boolean

true if this set changed as a result of the call

Annotations
@Override
See Also
java.util.Set#retainAll(java.util.Collection)
setTrackedAttributeNameback to summary
public void setTrackedAttributeName(String attributeName)

Implements org.eclipse.persistence.descriptors.changetracking.CollectionChangeTracker.setTrackedAttributeName.

INTERNAL: Set the mapping attribute name, used to raise change events. This is required if the change listener is set.

Annotations
@Override
setUseLazyInstantiationback to summary
public void setUseLazyInstantiation(boolean useLazyInstantiation)

Implements org.eclipse.persistence.indirection.IndirectCollection.setUseLazyInstantiation.

INTERNAL Set whether this collection should attempt do deal with adds and removes without retrieving the collection from the dB

Annotations
@Override
setValueHolderback to summary
public void setValueHolder(ValueHolderInterface<Set<E>> valueHolder)

Implements org.eclipse.persistence.indirection.IndirectContainer.setValueHolder.

INTERNAL: Set the value holder. Note that the delegate must be cleared out.

Annotations
@Override
shouldAvoidInstantiationback to summary
protected boolean shouldAvoidInstantiation()

INTERNAL: Return if add/remove should trigger instantiation or avoid. Current instantiation is avoided is using change tracking.

shouldUseLazyInstantiationback to summary
protected boolean shouldUseLazyInstantiation()

Return whether this collection should attempt do deal with adds and removes without retrieving the collection from the dB

sizeback to summary
public int size()

Implements java.util.Set.size.

Doc from java.util.Set.size.

Returns the number of elements in this set (its cardinality). If this set contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this set (its cardinality)

Annotations
@Override
See Also
java.util.Set#size()
spliteratorback to summary
public Spliterator<E> spliterator()

Overrides default java.util.Set.spliterator.

Doc from java.util.Set.spliterator.

Creates a Spliterator over the elements in this set.

The Spliterator reports Spliterator#DISTINCT. Implementations should document the reporting of additional characteristic values.

Returns:Spliterator<E>

a Spliterator over the elements in this set

Annotations
@Override
streamback to summary
public Stream<E> stream()

Overrides default java.util.Collection.stream.

Doc from java.util.Collection.stream.

Returns a sequential Stream with this collection as its source.

This method should be overridden when the spliterator() method cannot return a spliterator that is IMMUTABLE, CONCURRENT, or late-binding. (See spliterator() for details.)

Returns:Stream<E>

a sequential Stream over the elements in this collection

Annotations
@Override
toArrayback to summary
public Object[] toArray()

Implements java.util.Set.toArray.

Doc from java.util.Set.toArray.

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.

Returns:Object[]

an array containing all the elements in this set

Annotations
@Override
See Also
java.util.Set#toArray()
toArrayback to summary
public <T> T[] toArray(T[] a)

Implements java.util.Set.toArray.

Doc from java.util.Set.toArray.

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 null. (This is useful in determining the length of this set only if the caller knows that this set does not contain any null elements.)

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 toArray() method, this method acts as bridge between array-based and collection-based APIs. Further, this method allows precise control over the runtime type of the output array, and may, under certain circumstances, be used to save allocation costs.

Suppose x is a set known to contain only strings. The following code can be used to dump the set into a newly allocated array of String:

    String[] y = x.toArray(new String[0]);
Note that toArray(new Object[0]) is identical in function to toArray().
Parameters
<T>

Doc from java.util.Collection.toArray. the component type of the array to contain the collection

a: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.

Returns:T[]

an array containing all the elements in this set

Annotations
@Override
See Also
java.util.Set#toArray(java.lang.Object[])
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

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.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override
See Also
java.util.HashSet#toString()