Class ImmutableList<T>
- java.lang.Object
-
- org.apache.pivot.collections.ReadOnlySequence<T>
-
- org.apache.pivot.collections.immutable.ImmutableList<T>
-
- Type Parameters:
T- Type of elements in this list.
- All Implemented Interfaces:
java.io.Serializable,java.lang.Iterable<T>,Collection<T>,List<T>,Sequence<T>
public final class ImmutableList<T> extends ReadOnlySequence<T> implements List<T>
Unmodifiable implementation of theListinterface.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.pivot.collections.List
List.ItemIterator<T>, List.ListListenerList<T>
-
Nested classes/interfaces inherited from interface org.apache.pivot.collections.Sequence
Sequence.Tree<T>
-
-
Constructor Summary
Constructors Constructor Description ImmutableList(List<T> list)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Removes all elements from the collection.Tget(int index)Retrieves the item at the given index.java.util.Comparator<T>getComparator()Returns the collection's sort order.intgetLength()Returns the length of the list.ListenerList<ListListener<T>>getListListeners()Get the list of listeners for this list.intindexOf(T item)Returns the index of an item in the sequence.booleanisEmpty()Tests the emptiness of the collection.java.util.Iterator<T>iterator()voidsetComparator(java.util.Comparator<T> comparator)Sets the collection's sort order, re-ordering the collection's contents and ensuring that new entries preserve the sort order.java.lang.StringtoString()-
Methods inherited from class org.apache.pivot.collections.ReadOnlySequence
add, defaultException, insert, remove, remove, update
-
-
-
-
Method Detail
-
clear
@UnsupportedOperation public void clear()
Description copied from interface:CollectionRemoves all elements from the collection.- Specified by:
clearin interfaceCollection<T>- Specified by:
clearin interfaceList<T>- See Also:
ListListener.itemsRemoved(List, int, Sequence)
-
get
public T get(int index)
Description copied from interface:SequenceRetrieves the item at the given index.
-
indexOf
public int indexOf(T item)
Description copied from interface:SequenceReturns the index of an item in the sequence.
-
isEmpty
public boolean isEmpty()
Description copied from interface:CollectionTests the emptiness of the collection.- Specified by:
isEmptyin interfaceCollection<T>- Returns:
trueif the collection contains no elements;false, otherwise.
-
getLength
public int getLength()
Description copied from interface:ListReturns the length of the list.
-
getComparator
public java.util.Comparator<T> getComparator()
Description copied from interface:CollectionReturns the collection's sort order.- Specified by:
getComparatorin interfaceCollection<T>- Returns:
- The comparator used to order elements in the collection, or
nullif the sort order is undefined. - See Also:
Collection.setComparator(Comparator)
-
setComparator
@UnsupportedOperation public void setComparator(java.util.Comparator<T> comparator)
Description copied from interface:CollectionSets the collection's sort order, re-ordering the collection's contents and ensuring that new entries preserve the sort order.Calling this method more than once with the same comparator will re-sort the collection.
- Specified by:
setComparatorin interfaceCollection<T>- Specified by:
setComparatorin interfaceList<T>- Parameters:
comparator- The comparator used to order elements in the collection, or null if the collection is unsorted.- See Also:
ListListener.comparatorChanged(List, Comparator)
-
iterator
public java.util.Iterator<T> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<T>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getListListeners
public ListenerList<ListListener<T>> getListListeners()
Get the list of listeners for this list.Not clear why this would be used, since the listener(s) would only be called on changes to the list, which can't happen on an immutable list.
- Specified by:
getListListenersin interfaceList<T>- Returns:
- The list listener list.
-
-