org.omnaest.utils.structure.collection.list.decorator
Class ListDispatcher<E>
java.lang.Object
org.omnaest.utils.structure.collection.list.decorator.ListDispatcher<E>
- Type Parameters:
E -
- All Implemented Interfaces:
- Iterable<E>, Collection<E>, List<E>
- Direct Known Subclasses:
- SortedListDispatcher
public abstract class ListDispatcher<E>
- extends Object
- implements List<E>
Dispatches any access to it to one or multiple other List instances.
To use override any List method and use the protected #switchToNextInternalList(),
#switchToPreviousInternalList(), #getCurrentListIndex() and getList() methods to change the
List instance to which the method invocations are forwared.
By default the first List implementation is active.
- Author:
- Omnaest
listDispatchControl
protected final ListDispatcher.ListDispatchControl<E> listDispatchControl
ListDispatcher
public ListDispatcher(List<E>... lists)
- Parameters:
lists - - See Also:
ListDispatcher
size
public int size()
- Specified by:
size in interface Collection<E>- Specified by:
size in interface List<E>
- Returns:
- See Also:
List.size()
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty in interface Collection<E>- Specified by:
isEmpty in interface List<E>
- Returns:
- See Also:
List.isEmpty()
contains
public boolean contains(Object o)
- Specified by:
contains in interface Collection<E>- Specified by:
contains in interface List<E>
- Parameters:
o -
- Returns:
- See Also:
List.contains(java.lang.Object)
iterator
public Iterator<E> iterator()
- Specified by:
iterator in interface Iterable<E>- Specified by:
iterator in interface Collection<E>- Specified by:
iterator in interface List<E>
- Returns:
- See Also:
List.iterator()
toArray
public Object[] toArray()
- Specified by:
toArray in interface Collection<E>- Specified by:
toArray in interface List<E>
- Returns:
- See Also:
List.toArray()
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArray in interface Collection<E>- Specified by:
toArray in interface List<E>
- Parameters:
a -
- Returns:
- See Also:
java.util.List#toArray(T[])
add
public boolean add(E e)
- Specified by:
add in interface Collection<E>- Specified by:
add in interface List<E>
- Parameters:
e -
- Returns:
- See Also:
List.add(java.lang.Object)
remove
public boolean remove(Object o)
- Specified by:
remove in interface Collection<E>- Specified by:
remove in interface List<E>
- Parameters:
o -
- Returns:
- See Also:
List.remove(java.lang.Object)
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll in interface Collection<E>- Specified by:
containsAll in interface List<E>
- Parameters:
c -
- Returns:
- See Also:
List.containsAll(java.util.Collection)
addAll
public boolean addAll(Collection<? extends E> c)
- Specified by:
addAll in interface Collection<E>- Specified by:
addAll in interface List<E>
- Parameters:
c -
- Returns:
- See Also:
List.addAll(java.util.Collection)
addAll
public boolean addAll(int index,
Collection<? extends E> c)
- Specified by:
addAll in interface List<E>
- Parameters:
index - c -
- Returns:
- See Also:
List.addAll(int, java.util.Collection)
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAll in interface Collection<E>- Specified by:
removeAll in interface List<E>
- Parameters:
c -
- Returns:
- See Also:
List.removeAll(java.util.Collection)
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAll in interface Collection<E>- Specified by:
retainAll in interface List<E>
- Parameters:
c -
- Returns:
- See Also:
List.retainAll(java.util.Collection)
clear
public void clear()
- Specified by:
clear in interface Collection<E>- Specified by:
clear in interface List<E>
- See Also:
List.clear()
equals
public boolean equals(Object o)
- Specified by:
equals in interface Collection<E>- Specified by:
equals in interface List<E>- Overrides:
equals in class Object
- Parameters:
o -
- Returns:
- See Also:
List.equals(java.lang.Object)
hashCode
public int hashCode()
- Specified by:
hashCode in interface Collection<E>- Specified by:
hashCode in interface List<E>- Overrides:
hashCode in class Object
- Returns:
- See Also:
List.hashCode()
get
public E get(int index)
- Specified by:
get in interface List<E>
- Parameters:
index -
- Returns:
- See Also:
List.get(int)
set
public E set(int index,
E element)
- Specified by:
set in interface List<E>
- Parameters:
index - element -
- Returns:
- See Also:
List.set(int, java.lang.Object)
add
public void add(int index,
E element)
- Specified by:
add in interface List<E>
- Parameters:
index - element - - See Also:
List.add(int, java.lang.Object)
remove
public E remove(int index)
- Specified by:
remove in interface List<E>
- Parameters:
index -
- Returns:
- See Also:
List.remove(int)
indexOf
public int indexOf(Object o)
- Specified by:
indexOf in interface List<E>
- Parameters:
o -
- Returns:
- See Also:
List.indexOf(java.lang.Object)
lastIndexOf
public int lastIndexOf(Object o)
- Specified by:
lastIndexOf in interface List<E>
- Parameters:
o -
- Returns:
- See Also:
List.lastIndexOf(java.lang.Object)
listIterator
public ListIterator<E> listIterator()
- Specified by:
listIterator in interface List<E>
- Returns:
- See Also:
List.listIterator()
listIterator
public ListIterator<E> listIterator(int index)
- Specified by:
listIterator in interface List<E>
- Parameters:
index -
- Returns:
- See Also:
List.listIterator(int)
subList
public List<E> subList(int fromIndex,
int toIndex)
- Specified by:
subList in interface List<E>
- Parameters:
fromIndex - toIndex -
- Returns:
- See Also:
List.subList(int, int)
getList
protected List<E> getList()
- Returns:
toString
public String toString()
- Overrides:
toString in class Object
Copyright © 2013. All Rights Reserved.