Class ImmutableListCopy<E>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
org.infinispan.commons.util.ImmutableListCopy<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>, Immutables.Immutable

@Immutable public class ImmutableListCopy<E> extends AbstractList<E> implements Immutables.Immutable
A lightweight, read-only copy of a List. Typically used in place of the common idiom: return Collections.unmodifiableList(new ArrayList( myInternalList ));

a it is far more efficient than making a defensive copy and then wrapping the defensive copy in a read-only wrapper.

Also used whenever a read-only reference List is needed.

Since:
4.0
Author:
Manik Surtani ([email protected])