org.apache.commons.collections.buffer
Class PredicatedBuffer
- Buffer, Collection, Serializable
public class PredicatedBuffer
Decorates another
Buffer
to validate that additions
match a specified predicate.
This buffer exists to provide validation for the decorated buffer.
It is normally created to decorate an empty buffer.
If an object cannot be added to the buffer, an IllegalArgumentException is thrown.
One usage would be to ensure that no null entries are added to the buffer.
Buffer buffer = PredicatedBuffer.decorate(new UnboundedFifoBuffer(), NotNullPredicate.INSTANCE);
This class is Serializable from Commons Collections 3.1.
$Revision: 1.7 $ $Date: 2004/06/03 22:02:13 $- Stephen Colebourne
- Paul Jack
static Buffer | decorate(Buffer buffer, Predicate predicate) - Factory method to create a predicated (validating) buffer.
|
Object | get() - Gets the next object from the buffer without removing it.
|
protected Buffer | getBuffer() - Gets the buffer being decorated.
|
Object | remove() - Gets and removes the next object from the buffer.
|
add , addAll , clear , contains , containsAll , equals , getCollection , hashCode , isEmpty , iterator , remove , removeAll , retainAll , size , toArray , toArray , toString |
PredicatedBuffer
protected PredicatedBuffer(Buffer buffer,
Predicate predicate)
Constructor that wraps (not copies).
If there are any elements already in the collection being decorated, they
are validated.
buffer
- the buffer to decorate, must not be nullpredicate
- the predicate to use for validation, must not be null
decorate
public static Buffer decorate(Buffer buffer,
Predicate predicate)
Factory method to create a predicated (validating) buffer.
If there are any elements already in the buffer being decorated, they
are validated.
buffer
- the buffer to decorate, must not be nullpredicate
- the predicate to use for validation, must not be null
get
public Object get()
Gets the next object from the buffer without removing it.
- get in interface Buffer
- the next object in the buffer, which is not removed
getBuffer
protected Buffer getBuffer()
Gets the buffer being decorated.
remove
public Object remove()
Gets and removes the next object from the buffer.
- remove in interface Buffer
- the next object in the buffer, which is also removed
Copyright © 2001-2006 Apache Software Foundation. All Rights Reserved.