Top Description Constructors Methods
org.apache.commons.collections4.functors

public abstract Class CatchAndRethrowClosure<E>

extends Object
implements Closure<E>
Class Inheritance
All Implemented Interfaces
org.apache.commons.collections4.Closure
Imports
org.apache.commons.collections4.Closure, .FunctorException

Closure that catches any checked exception and re-throws it as a FunctorException runtime exception. Example usage:
// Create a catch and re-throw closure via anonymous subclass
CatchAndRethrowClosure<String> writer = new ThrowingClosure() {
    private java.io.Writer out = // some writer

    protected void executeAndThrow(String input) throws IOException {
        out.write(input); // throwing of IOException allowed
    }
};

// use catch and re-throw closure
java.util.List<String> strList = // some list
try {
    CollectionUtils.forAllDo(strList, writer);
} catch (FunctorException ex) {
    Throwable originalError = ex.getCause();
    // handle error
}
Since
4.0

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
execute(final E
the input to execute on
input
)

Implements org.apache.commons.collections4.Closure.execute.

Execute this closure on the specified input object.
protected abstract void
executeAndThrow(E
the input to execute on
input
)

Execute this closure on the specified input object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

CatchAndRethrowClosureback to summary
public CatchAndRethrowClosure()

Method Detail

executeback to summary
public void execute(final E input)

Implements org.apache.commons.collections4.Closure.execute.

Execute this closure on the specified input object.

Parameters
input:E

the input to execute on

Annotations
@Override
Exceptions
FunctorException:
(runtime) if the closure execution resulted in a checked exception.
executeAndThrowback to summary
protected abstract void executeAndThrow(E input) throws Throwable

Execute this closure on the specified input object.

Parameters
input:E

the input to execute on

Exceptions
Throwable:
if the closure execution resulted in a checked exception.