Package org.infinispan.commons.util
Class ImmutableListCopy<E>
- java.lang.Object
- 
- java.util.AbstractCollection<E>
- 
- java.util.AbstractList<E>
- 
- org.infinispan.commons.util.ImmutableListCopy<E>
 
 
 
- 
- All Implemented Interfaces:
- Externalizable,- Serializable,- Iterable<E>,- Collection<E>,- List<E>,- Immutables.Immutable
 
 @Immutable public class ImmutableListCopy<E> extends AbstractList<E> implements Externalizable, 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 (manik@jboss.org)
- See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description classImmutableListCopy.ImmutableSubList<E>
 - 
Field Summary- 
Fields inherited from class java.util.AbstractListmodCount
 
- 
 - 
Constructor SummaryConstructors Constructor Description ImmutableListCopy()Constructs a new ImmutableListCopy.ImmutableListCopy(E[] array)Assumes that the array passed in is "safe", i.e., is not referenced from elsewhere.ImmutableListCopy(Collection<? extends E> c)Only one copy constructor since the list is immutable.ImmutableListCopy(Collection<? extends E> collection1, Collection<? extends E> collection2)Utility constructors to allow combining collections
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E o)booleanaddAll(int index, Collection<? extends E> c)booleanaddAll(Collection<? extends E> c)booleancontains(Object o)booleanequals(Object o)Eget(int index)inthashCode()intindexOf(Object o)booleanisEmpty()Iterator<E>iterator()intlastIndexOf(Object o)ListIterator<E>listIterator()ListIterator<E>listIterator(int index)voidreadExternal(ObjectInput in)SeewriteExternal(java.io.ObjectOutput)for serialization formatbooleanremove(Object o)booleanremoveAll(Collection<?> c)booleanretainAll(Collection<?> c)intsize()List<E>subList(int fromIndex, int toIndex)Object[]toArray()<T> T[]toArray(T[] a)voidwriteExternal(ObjectOutput out)Format: - entry array size (int) - elements (Object)- 
Methods inherited from class java.util.AbstractListadd, clear, remove, removeRange, set
 - 
Methods inherited from class java.util.AbstractCollectioncontainsAll, toString
 - 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface java.util.CollectionparallelStream, removeIf, stream, toArray
 - 
Methods inherited from interface java.util.ListcontainsAll, replaceAll, sort, spliterator
 
- 
 
- 
- 
- 
Constructor Detail- 
ImmutableListCopypublic ImmutableListCopy() Constructs a new ImmutableListCopy. Required by Serialization.
 - 
ImmutableListCopypublic ImmutableListCopy(Collection<? extends E> c) Only one copy constructor since the list is immutable.- Parameters:
- c- collection to copy from
 
 - 
ImmutableListCopypublic ImmutableListCopy(E[] array) Assumes that the array passed in is "safe", i.e., is not referenced from elsewhere. Use with care!- Parameters:
- array- to reference
 
 - 
ImmutableListCopypublic ImmutableListCopy(Collection<? extends E> collection1, Collection<? extends E> collection2) Utility constructors to allow combining collections- Parameters:
- collection1- collection to copy from
- collection2- collection to copy from
 
 
- 
 - 
Method Detail- 
sizepublic final int size() - Specified by:
- sizein interface- Collection<E>
- Specified by:
- sizein interface- List<E>
- Specified by:
- sizein class- AbstractCollection<E>
 
 - 
isEmptypublic final boolean isEmpty() - Specified by:
- isEmptyin interface- Collection<E>
- Specified by:
- isEmptyin interface- List<E>
- Overrides:
- isEmptyin class- AbstractCollection<E>
 
 - 
containspublic final boolean contains(Object o) - Specified by:
- containsin interface- Collection<E>
- Specified by:
- containsin interface- List<E>
- Overrides:
- containsin class- AbstractCollection<E>
 
 - 
toArraypublic final Object[] toArray() - Specified by:
- toArrayin interface- Collection<E>
- Specified by:
- toArrayin interface- List<E>
- Overrides:
- toArrayin class- AbstractCollection<E>
 
 - 
toArraypublic final <T> T[] toArray(T[] a) - Specified by:
- toArrayin interface- Collection<E>
- Specified by:
- toArrayin interface- List<E>
- Overrides:
- toArrayin class- AbstractCollection<E>
 
 - 
addpublic final boolean add(E o) - Specified by:
- addin interface- Collection<E>
- Specified by:
- addin interface- List<E>
- Overrides:
- addin class- AbstractList<E>
 
 - 
removepublic final boolean remove(Object o) - Specified by:
- removein interface- Collection<E>
- Specified by:
- removein interface- List<E>
- Overrides:
- removein class- AbstractCollection<E>
 
 - 
addAllpublic final boolean addAll(Collection<? extends E> c) - Specified by:
- addAllin interface- Collection<E>
- Specified by:
- addAllin interface- List<E>
- Overrides:
- addAllin class- AbstractCollection<E>
 
 - 
addAllpublic final boolean addAll(int index, Collection<? extends E> c)
 - 
removeAllpublic final boolean removeAll(Collection<?> c) - Specified by:
- removeAllin interface- Collection<E>
- Specified by:
- removeAllin interface- List<E>
- Overrides:
- removeAllin class- AbstractCollection<E>
 
 - 
retainAllpublic final boolean retainAll(Collection<?> c) - Specified by:
- retainAllin interface- Collection<E>
- Specified by:
- retainAllin interface- List<E>
- Overrides:
- retainAllin class- AbstractCollection<E>
 
 - 
getpublic final E get(int index) 
 - 
indexOfpublic final int indexOf(Object o) 
 - 
lastIndexOfpublic final int lastIndexOf(Object o) - Specified by:
- lastIndexOfin interface- List<E>
- Overrides:
- lastIndexOfin class- AbstractList<E>
 
 - 
listIteratorpublic final ListIterator<E> listIterator() - Specified by:
- listIteratorin interface- List<E>
- Overrides:
- listIteratorin class- AbstractList<E>
 
 - 
listIteratorpublic final ListIterator<E> listIterator(int index) - Specified by:
- listIteratorin interface- List<E>
- Overrides:
- listIteratorin class- AbstractList<E>
 
 - 
equalspublic boolean equals(Object o) - Specified by:
- equalsin interface- Collection<E>
- Specified by:
- equalsin interface- List<E>
- Overrides:
- equalsin class- AbstractList<E>
 
 - 
hashCodepublic int hashCode() - Specified by:
- hashCodein interface- Collection<E>
- Specified by:
- hashCodein interface- List<E>
- Overrides:
- hashCodein class- AbstractList<E>
 
 - 
writeExternalpublic void writeExternal(ObjectOutput out) throws IOException Format: - entry array size (int) - elements (Object)- Specified by:
- writeExternalin interface- Externalizable
- Parameters:
- out- stream to write to
- Throws:
- IOException
 
 - 
readExternalpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException SeewriteExternal(java.io.ObjectOutput)for serialization format- Specified by:
- readExternalin interface- Externalizable
- Parameters:
- in- stream
- Throws:
- IOException
- ClassNotFoundException
 
 
- 
 
-