Top Description Inners Fields Constructors Methods
org.eclipse.persistence.jpa.jpql.tools.utility.iterable

public Class SnapshotCloneIterable<E>

extends CloneIterable<E>
Class Inheritance
Type Parameters
<E>
the type of elements returned by the iterable's iterator
Imports
java.util.Arrays, .Collection, .Iterator, org.eclipse.persistence.jpa.jpql.tools.utility.iterator.CloneIterator, org.eclipse.persistence.jpa.jpql.utility.CollectionTools

A SnapshotCloneIterable returns an iterator on a "snapshot" of a collection, allowing for concurrent access to the original collection. A copy of the collection is created when the iterable is constructed. As a result, the contents of the collection will be the same with every call to iterator().

The original collection passed to the SnapshotCloneIterable's constructor should be thread-safe (e.g. java.util.Vector); otherwise you run the risk of a corrupted collection.

By default, the iterator returned by a SnapshotCloneIterable does not support the Iterator#remove() operation; this is because it does not have access to the original collection. But if the SnapshotCloneIterable is supplied with a CloneIterator.Remover it will delegate the Iterator#remove() operation to the Remover. Alternatively, a subclass can override the iterable's remove(Object) method.

This iterable is useful for multiple passes over a collection that should not be changed (e.g. by another thread) between passes.

See Also
CloneIterator, LiveCloneIterable, SnapshotCloneListIterable

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
SnapshotCloneIterable.LocalCloneIterator<E>

provide access to "internal" constructor

Field Summary

Modifier and TypeField and Description
private final Object[]
Inherited from org.eclipse.persistence.jpa.jpql.tools.utility.iterable.CloneIterable:
remover

Constructor Summary

AccessConstructor and Description
public
SnapshotCloneIterable(Iterator<? extends E> iterator)

Construct a "snapshot" iterable for the specified iterator.

public
SnapshotCloneIterable(Iterator<? extends E> iterator, CloneIterator.Remover<E> remover)

Construct a "snapshot" iterable for the specified iterator.

public
SnapshotCloneIterable(Collection<? extends E> collection)

Construct a "snapshot" iterable for the specified collection.

public
SnapshotCloneIterable(Collection<? extends E> collection, CloneIterator.Remover<E> remover)

Construct a "snapshot" iterable for the specified collection.

Method Summary

Modifier and TypeMethod and Description
public Iterator<E>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from org.eclipse.persistence.jpa.jpql.tools.utility.iterable.CloneIterable:
buildDefaultRemoverremove

Field Detail

arrayback to summary
private final Object[] array

Constructor Detail

SnapshotCloneIterableback to summary
public SnapshotCloneIterable(Iterator<? extends E> iterator)

Construct a "snapshot" iterable for the specified iterator. The Iterator#remove() operation will not be supported by the iterator returned by iterator() unless a subclass overrides the iterable's remove(Object) method.

SnapshotCloneIterableback to summary
public SnapshotCloneIterable(Iterator<? extends E> iterator, CloneIterator.Remover<E> remover)

Construct a "snapshot" iterable for the specified iterator. The specified remover will be used by any generated iterators to remove objects from the original collection.

SnapshotCloneIterableback to summary
public SnapshotCloneIterable(Collection<? extends E> collection)

Construct a "snapshot" iterable for the specified collection. The Iterator#remove() operation will not be supported by the iterator returned by iterator() unless a subclass overrides the iterable's remove(Object) method.

SnapshotCloneIterableback to summary
public SnapshotCloneIterable(Collection<? extends E> collection, CloneIterator.Remover<E> remover)

Construct a "snapshot" iterable for the specified collection. The specified remover will be used by any generated iterators to remove objects from the original collection.

Method Detail

iteratorback to summary
public Iterator<E> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<E>

an Iterator.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.eclipse.persistence.jpa.jpql.tools.utility.iterable back to summary

protected Class SnapshotCloneIterable.LocalCloneIterator<E>

extends CloneIterator<E>
Class Inheritance

provide access to "internal" constructor

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Inherited from org.eclipse.persistence.jpa.jpql.tools.utility.iterator.CloneIterator:
hasNextnestedNextnextremoveremove

Constructor Detail

LocalCloneIteratorback to summary
protected LocalCloneIterator(CloneIterator.Remover<E> remover, Object[] array)