Class SnapshotCloneListIterable<E>
- java.lang.Object
-
- org.eclipse.persistence.jpa.jpql.utility.iterable.CloneListIterable<E>
-
- org.eclipse.persistence.jpa.jpql.utility.iterable.SnapshotCloneListIterable<E>
-
- Type Parameters:
E
- the type of elements returned by the list iterable's list iterator
- All Implemented Interfaces:
java.lang.Iterable<E>
,ListIterable<E>
public class SnapshotCloneListIterable<E> extends CloneListIterable<E>
ASnapshotCloneListIterable
returns a list iterator on a "snapshot" of a list, allowing for concurrent access to the original list. A copy of the list is created when the list iterable is constructed. As a result, the contents of the list will be the same with every call toiterator()
, even if the original list is modified via the list iterator's mutation methods.The original list passed to the
SnapshotCloneListIterable
's constructor should be thread-safe (e.g.Vector
); otherwise you run the risk of a corrupted list.By default, the list iterator returned by a
SnapshotCloneListIterable
does not support theListIterator
mutation operations; this is because it does not have access to the original list. But if theSnapshotCloneListIterable
is supplied with aCloneListIterator.Mutator
it will delegate theListIterator
mutation operations to theMutator
. Alternatively, a subclass can override the list iterable's mutation methods.This list iterable is useful for multiple passes over a list that should not be changed (e.g. by another thread) between passes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
SnapshotCloneListIterable.LocalCloneListIterator<E>
provide access to "internal" constructor-
Nested classes/interfaces inherited from class org.eclipse.persistence.jpa.jpql.utility.iterable.CloneListIterable
CloneListIterable.DefaultMutator
-
-
Constructor Summary
Constructors Constructor Description SnapshotCloneListIterable(java.util.List<? extends E> list)
Construct a "snapshot" list iterable for the specified list.SnapshotCloneListIterable(java.util.List<? extends E> list, CloneListIterator.Mutator<E> mutator)
Construct a "snapshot" list iterable for the specified list.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.ListIterator<E>
iterator()
java.lang.String
toString()
-
Methods inherited from class org.eclipse.persistence.jpa.jpql.utility.iterable.CloneListIterable
add, buildDefaultMutator, remove, set
-
-
-
-
Constructor Detail
-
SnapshotCloneListIterable
public SnapshotCloneListIterable(java.util.List<? extends E> list)
Construct a "snapshot" list iterable for the specified list. TheListIterator
modify operations will not be supported by the list iterator returned byiterator()
unless a subclass overrides the list iterable's modify method.
-
SnapshotCloneListIterable
public SnapshotCloneListIterable(java.util.List<? extends E> list, CloneListIterator.Mutator<E> mutator)
Construct a "snapshot" list iterable for the specified list. The specified mutator will be used by any generated list iterators to modify the original list.
-
-
Method Detail
-
iterator
public java.util.ListIterator<E> iterator()
Description copied from interface:ListIterable
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-