com.azalient.api.a.store
Class ListAdapter<T>

java.lang.Object
  extended by com.azalient.api.a.store.ListAdapter<T>
Type Parameters:
T - the class of the objects in the array or list
All Implemented Interfaces:
IList<T>, Iterable<T>

public class ListAdapter<T>
extends Object
implements IList<T>

An adapter to allow a List, an ArrayList or an array of objects to expose an IList interface


Constructor Summary
ListAdapter(ArrayList<T> a)
          Create an adapter based on the given ArrayList.
ListAdapter(List<T> a)
          Create an adapter based on the given List of objects.
ListAdapter(T[] a)
          Create an adapter based on the given array of objects.
 
Method Summary
 Collection<T> collection()
          Return the objects as a collection
 T get(int index)
          The index'th element in the list
 Iterator<T> iterator()
          Returns an iterator over a set of elements of type I.
 int size()
          The number of elements in the list
 T[] toArray(T[] ta)
          Convert the list to an array.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListAdapter

public ListAdapter(ArrayList<T> a)
Create an adapter based on the given ArrayList. The parameter can be null, which will cause a new List to be created. Otherwise the existing list will be used


ListAdapter

public ListAdapter(List<T> a)
Create an adapter based on the given List of objects. The parameter can be null, which will cause a new List to be created. Otherwise the existing list will be used


ListAdapter

public ListAdapter(T[] a)
Create an adapter based on the given array of objects. The parameter can be null, which will cause a new List to be created. Otherwise a list will be created from the given array, using Arrays.asList(Object...)

Method Detail

iterator

public Iterator<T> iterator()
Returns an iterator over a set of elements of type I.

Specified by:
iterator in interface Iterable<T>
Returns:
an Iterator.

size

public int size()
Description copied from interface: IList
The number of elements in the list

Specified by:
size in interface IList<T>

get

public T get(int index)
Description copied from interface: IList
The index'th element in the list

Specified by:
get in interface IList<T>

toArray

public T[] toArray(T[] ta)
Description copied from interface: IList
Convert the list to an array. The array passed in cannot be null, it must be of the correct type, but it can be of type zero.

Specified by:
toArray in interface IList<T>

collection

public Collection<T> collection()
Return the objects as a collection