Package org.apache.juneau.collections
Class ControlledArrayList<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<E>
org.apache.juneau.collections.ControlledArrayList<E>
- Type Parameters:
- E- The element type.
- All Implemented Interfaces:
- Serializable,- Cloneable,- Iterable<E>,- Collection<E>,- List<E>,- RandomAccess
- Direct Known Subclasses:
- HeaderList,- PartList
An array list that allows you to control whether it's read-only via a constructor parameter.
 
 Override methods such as overrideAdd(int, Object) are provided that bypass the unmodifiable restriction
 on the list.  They allow you to manipulate the list while not exposing the ability to manipulate the list through
 any of the methods provided by the List interface (meaning you can pass the object around as an unmodifiable List).
- See Also:
- 
Field SummaryFields inherited from class java.util.AbstractListmodCount
- 
Constructor SummaryConstructorsConstructorDescriptionControlledArrayList(boolean unmodifiable) Constructor.ControlledArrayList(boolean unmodifiable, List<? extends E> list) Constructor.
- 
Method SummaryModifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int index, Collection<? extends E> c) booleanaddAll(Collection<? extends E> c) protected final voidThrows anUnsupportedOperationExceptionif the unmodifiable flag is set on this bean.voidclear()booleanReturnstrue if this list is modifiable.iterator()listIterator(int index) voidoverrideAdd(int index, E element) Same asadd(int, Object)but bypasses the modifiable flag.booleanoverrideAdd(E element) Same asadd(Object)but bypasses the modifiable flag.booleanoverrideAddAll(int index, Collection<? extends E> c) Same asaddAll(int,Collection)but bypasses the modifiable flag.booleanoverrideAddAll(Collection<? extends E> c) Same asaddAll(Collection)but bypasses the modifiable flag.voidSame asclear()but bypasses the modifiable flag.Same asiterator()but bypasses the modifiable flag.overrideListIterator(int index) Same aslistIterator()but bypasses the modifiable flag.overrideRemove(int index) Same asremove(int)but bypasses the modifiable flag.booleanSame asremove(Object)but bypasses the modifiable flag.booleanoverrideRemoveAll(Collection<?> c) Same asremoveAll(Collection)but bypasses the modifiable flag.booleanoverrideRemoveIf(Predicate<? super E> filter) Same asremoveIf(Predicate)but bypasses the modifiable flag.voidoverrideReplaceAll(UnaryOperator<E> operator) Same asreplaceAll(UnaryOperator)but bypasses the modifiable flag.booleanoverrideRetainAll(Collection<?> c) Same asretainAll(Collection)but bypasses the modifiable flag.overrideSet(int index, E element) Same asset(int, Object)but bypasses the modifiable flag.voidoverrideSort(Comparator<? super E> c) Same asoverrideSort(Comparator)but bypasses the modifiable flag.remove(int index) booleanbooleanremoveAll(Collection<?> coll) booleanvoidreplaceAll(UnaryOperator<E> operator) booleanretainAll(Collection<?> c) Specifies whether this bean should be unmodifiable.voidsort(Comparator<? super E> c) subList(int fromIndex, int toIndex) Methods inherited from class java.util.ArrayListclone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, lastIndexOf, removeRange, size, spliterator, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollectioncontainsAll, toStringMethods inherited from class java.lang.Objectfinalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.CollectionparallelStream, stream, toArrayMethods inherited from interface java.util.ListcontainsAll
- 
Constructor Details- 
ControlledArrayListConstructor.- Parameters:
- unmodifiable- If- true , this list cannot be modified through normal list operation methods on the- Listinterface.
 
- 
ControlledArrayListConstructor.- Parameters:
- unmodifiable- If- true , this list cannot be modified through normal list operation methods on the- Listinterface.
- list- The initial contents of this list.
 
 
- 
- 
Method Details- 
setUnmodifiableSpecifies whether this bean should be unmodifiable.When enabled, attempting to set any properties on this bean will cause an UnsupportedOperationException.- Returns:
- This object.
 
- 
assertModifiableThrows anUnsupportedOperationExceptionif the unmodifiable flag is set on this bean.
- 
isModifiableReturnstrue if this list is modifiable.- Returns:
- true if this list is modifiable.
 
- 
set
- 
overrideSetSame asset(int, Object)but bypasses the modifiable flag.- Parameters:
- index- Index of the element to replace.
- element- Element to be stored at the specified position.
- Returns:
- The element previously at the specified position.
 
- 
add
- 
overrideAddSame asadd(int, Object)but bypasses the modifiable flag.- Parameters:
- index- Index of the element to replace.
- element- Element to be stored at the specified position.
 
- 
remove
- 
overrideRemoveSame asremove(int)but bypasses the modifiable flag.- Parameters:
- index- Index of the element to remove.
- Returns:
- The element that was removed from the list.
 
- 
addAll
- 
overrideAddAllSame asaddAll(int,Collection)but bypasses the modifiable flag.- Parameters:
- index- Index at which to insert the first element from the specified collection.
- c- Collection containing elements to be added to this list.
- Returns:
- true if this list changed as a result of the call.
 
- 
replaceAll- Specified by:
- replaceAllin interface- List<E>
- Overrides:
- replaceAllin class- ArrayList<E>
 
- 
overrideReplaceAllSame asreplaceAll(UnaryOperator)but bypasses the modifiable flag.- Parameters:
- operator- The operator to apply to each element.
 
- 
sort
- 
overrideSortSame asoverrideSort(Comparator)but bypasses the modifiable flag.- Parameters:
- c- The Comparator used to compare list elements. A null value indicates that the elements' natural ordering should be used.
 
- 
add
- 
overrideAddSame asadd(Object)but bypasses the modifiable flag.- Parameters:
- element- Element to be stored at the specified position.
- Returns:
- true .
 
- 
remove
- 
overrideRemoveSame asremove(Object)but bypasses the modifiable flag.- Parameters:
- o- Element to be removed from this list, if present.
- Returns:
- true if this list contained the specified element.
 
- 
addAll
- 
overrideAddAllSame asaddAll(Collection)but bypasses the modifiable flag.- Parameters:
- c- Collection containing elements to be added to this list.
- Returns:
- true if this list changed as a result of the call.
 
- 
removeAll
- 
overrideRemoveAllSame asremoveAll(Collection)but bypasses the modifiable flag.- Parameters:
- c- Collection containing elements to be removed from this list.
- Returns:
- true if this list changed as a result of the call.
 
- 
retainAll
- 
overrideRetainAllSame asretainAll(Collection)but bypasses the modifiable flag.- Parameters:
- c- Collection containing elements to be retained in this list.
- Returns:
- true if this list changed as a result of the call.
 
- 
clear
- 
overrideClearSame asclear()but bypasses the modifiable flag.
- 
removeIf
- 
overrideRemoveIfSame asremoveIf(Predicate)but bypasses the modifiable flag.- Parameters:
- filter- A predicate which returns true for elements to be removed.
- Returns:
- true if any elements were removed.
 
- 
subList
- 
listIterator- Specified by:
- listIteratorin interface- List<E>
- Overrides:
- listIteratorin class- ArrayList<E>
 
- 
listIterator- Specified by:
- listIteratorin interface- List<E>
- Overrides:
- listIteratorin class- ArrayList<E>
 
- 
overrideListIteratorSame aslistIterator()but bypasses the modifiable flag.- Parameters:
- index- Index of the first element to be returned from the list iterator.
- Returns:
- A list iterator over the elements in this list (in proper sequence), starting at the specified position in the list.
 
- 
iterator
- 
overrideIteratorSame asiterator()but bypasses the modifiable flag.- Returns:
- An iterator over the elements in this list in proper sequence.
 
 
-