java.util.Collection Extensions

Adds various function extensions to java.util.List implementations.

Property Summary
int length
Provides the current size of the collection.


Function Summary
void each(Function func)
Iterates through the collection and for each element, calls the passed function with the element as the parameter.
Object find(Function func)
Finds the first item selected by the passed function.
java.util.List findAll(Function func)
Finds all items selected by the passed function.

Properties

length

int length

Provides the current size of the collection. Alternative to the size() method to be more consistent with Javascript arrays.

Functions

each

void each(Function func)

Iterates through the collection and for each element, calls the passed function with the element as the parameter.

Example:
list.each(function(item) { print(item) })

find

Object find(Function func)

Finds the first item selected by the passed function. The function will receive the item and should return true or false for the result.

Example:
item = list.find(function(item) { return item.matches(/foo[0-9]/) })

findAll

java.util.List findAll(Function func)

Finds all items selected by the passed function. The function will receive the item and should return true or false for the result. A list of all matches will be returned.

Example:
matches = list.findAll(function(item) { return item.matches(/foo[0-9]/) })