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

Class PredicatedBuffer

java.lang.Object
|
+--org.apache.commons.collections.collection.AbstractCollectionDecorator
   |
   +--org.apache.commons.collections.collection.PredicatedCollection
      |
      +--org.apache.commons.collections.buffer.PredicatedBuffer

All Implemented Interfaces:
Collection, Buffer


public class PredicatedBuffer
extends PredicatedCollection
implements Buffer

Decorates another Buffer to validate that additions match a specified predicate.

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

Since:
Commons Collections 3.0
Authors:
Stephen Colebourne
Paul Jack

Constructor Summary

PredicatedBuffer(Buffer buffer, Predicate predicate)

Constructor that wraps (not copies).

Method Summary

static Buffer

decorate(Buffer buffer, Predicate predicate)

Factory method to create a predicated (validating) buffer.

Object

get()

Buffer

getBuffer()

Gets the buffer being decorated.

Object

remove()

Constructor Details

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.

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

Method Details

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.

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

get

public Object get()


getBuffer

protected Buffer getBuffer()

Gets the buffer being decorated.

Returns:
the decorated buffer

remove

public Object remove()