⇒ Index (Frames) |  ⇒ Index (No Frames) |  ⇒ Package |  ⇒ Package Tree |  ⇒ Full Tree 
org.apache.commons.collections.list

Class PredicatedList

java.lang.Object
|
+--org.apache.commons.collections.collection.AbstractCollectionDecorator
   |
   +--org.apache.commons.collections.collection.PredicatedCollection
      |
      +--org.apache.commons.collections.list.PredicatedList

All Implemented Interfaces:
Collection, List


public class PredicatedList
extends PredicatedCollection
implements List

Decorates another List to validate that all additions match a specified predicate.

If an object cannot be added to the list, an IllegalArgumentException is thrown.

Since:
Commons Collections 3.0
Authors:
Stephen Colebourne
Paul Jack

Constructor Summary

PredicatedList(List list, Predicate predicate)

Constructor that wraps (not copies).

Method Summary

void

add(int index, Object object)

boolean

addAll(int index, Collection coll)

static List

decorate(List list, Predicate predicate)

Factory method to create a predicated (validating) list.

Object

get(int index)

List

getList()

Gets the list being decorated.

int

indexOf(Object object)

int

lastIndexOf(Object object)

ListIterator

listIterator()

ListIterator

listIterator(int i)

Object

remove(int index)

Object

set(int index, Object object)

List

subList(int fromIndex, int toIndex)

Constructor Details

PredicatedList

protected PredicatedList(List list, Predicate predicate)

Constructor that wraps (not copies).

If there are any elements already in the list being decorated, they are validated.

Parameters:
list - the list to decorate, must not be null
predicate - the predicate to use for validation, must not be null
Throws:
- if list or predicate is null
- if the list contains invalid elements

Method Details

add

public void add(int index, Object object)

Parameters:
index
object

addAll

public boolean addAll(int index, Collection coll)

Parameters:
index
coll

decorate

public static List decorate(List list, Predicate predicate)

Factory method to create a predicated (validating) list.

If there are any elements already in the list being decorated, they are validated.

Parameters:
list - the list to decorate, must not be null
predicate - the predicate to use for validation, must not be null
Throws:
- if list or predicate is null
- if the list contains invalid elements

get

public Object get(int index)

Parameters:
index

getList

protected List getList()

Gets the list being decorated.

Returns:
the decorated list

indexOf

public int indexOf(Object object)

Parameters:
object

lastIndexOf

public int lastIndexOf(Object object)

Parameters:
object

listIterator

public ListIterator listIterator()


listIterator

public ListIterator listIterator(int i)

Parameters:
i

remove

public Object remove(int index)

Parameters:
index

set

public Object set(int index, Object object)

Parameters:
index
object

subList

public List subList(int fromIndex, int toIndex)

Parameters:
fromIndex
toIndex