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 theList
interface.- 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 void
clear()
Removes all elements from the collection.T
get(int index)
Retrieves the item at the given index.java.util.Comparator<T>
getComparator()
Returns the collection's sort order.int
getLength()
Returns the length of the list.ListenerList<ListListener<T>>
getListListeners()
Get the list of listeners for this list.int
indexOf(T item)
Returns the index of an item in the sequence.boolean
isEmpty()
Tests the emptiness of the collection.java.util.Iterator<T>
iterator()
void
setComparator(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.String
toString()
-
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:Collection
Removes all elements from the collection.- Specified by:
clear
in interfaceCollection<T>
- Specified by:
clear
in interfaceList<T>
- See Also:
ListListener.itemsRemoved(List, int, Sequence)
-
get
public T get(int index)
Description copied from interface:Sequence
Retrieves the item at the given index.
-
indexOf
public int indexOf(T item)
Description copied from interface:Sequence
Returns the index of an item in the sequence.
-
isEmpty
public boolean isEmpty()
Description copied from interface:Collection
Tests the emptiness of the collection.- Specified by:
isEmpty
in interfaceCollection<T>
- Returns:
true
if the collection contains no elements;false
, otherwise.
-
getLength
public int getLength()
Description copied from interface:List
Returns the length of the list.
-
getComparator
public java.util.Comparator<T> getComparator()
Description copied from interface:Collection
Returns the collection's sort order.- Specified by:
getComparator
in interfaceCollection<T>
- Returns:
- The comparator used to order elements in the collection, or
null
if the sort order is undefined. - See Also:
Collection.setComparator(Comparator)
-
setComparator
@UnsupportedOperation public void setComparator(java.util.Comparator<T> comparator)
Description copied from interface:Collection
Sets 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:
setComparator
in interfaceCollection<T>
- Specified by:
setComparator
in 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:
iterator
in interfacejava.lang.Iterable<T>
-
toString
public java.lang.String toString()
- Overrides:
toString
in 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:
getListListeners
in interfaceList<T>
- Returns:
- The list listener list.
-
-