Class CommonsCollections4Helper
- java.lang.Object
-
- ch.powerunit.extensions.exceptions.CommonsCollections4Helper
-
public final class CommonsCollections4Helper extends Object
This class provides several helper methods for the functional interface of the commons-collections4.This class is only available if commons-collections4 is available
The mapping between the interface from commons-collections4 and this library is the following :
Mapping between interfaces commons-collections4 powerunit-extensions-exceptions Predicate PredicateWithException Factory SupplierWithException Transformer FunctionWithException Closure ConsumerWithException - Since:
- 2.2.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> org.apache.commons.collections4.Closure<T>
asClosure(ConsumerWithException<T,?> consumer)
Transforms aConsumerWithException
to the one from commons-collections.static <T> org.apache.commons.collections4.Factory<T>
asFactory(SupplierWithException<T,?> supplier)
Transforms aSupplierWithException
to the one from commons-collections.static <T> org.apache.commons.collections4.Predicate<T>
asPredicate(PredicateWithException<T,?> predicate)
Transforms aPredicateWithException
to the one from commons-collections.static <I,O> org.apache.commons.collections4.Transformer<I,O>
asTransformer(FunctionWithException<I,O,?> function)
Transforms aFunctionWithException
to the one from commons-collections.
-
-
-
Method Detail
-
asPredicate
public static <T> org.apache.commons.collections4.Predicate<T> asPredicate(PredicateWithException<T,?> predicate)
Transforms aPredicateWithException
to the one from commons-collections.- Type Parameters:
T
- the type of the input argument for the predicate- Parameters:
predicate
- thePredicateWithException
to be transformed to the one from commons-collections.- Returns:
- the
predicate
from commons-collections. The ClassCastException and IllegalArgumentException are not wrapped and the other exception are wrapped in a FunctorException. - Throws:
NoClassDefFoundError
- In case the commons-collections4 library is not available.NullPointerException
- if predicate is null.- See Also:
Predicate
-
asFactory
public static <T> org.apache.commons.collections4.Factory<T> asFactory(SupplierWithException<T,?> supplier)
Transforms aSupplierWithException
to the one from commons-collections.- Type Parameters:
T
- the type of the result of the supplier- Parameters:
supplier
- theSupplierWithException
to be transformed to the one from commons-collections.- Returns:
- the
factory
from commons-collections. The exception are wrapped in a FunctorException. - Throws:
NoClassDefFoundError
- In case the commons-collections4 library is not available.NullPointerException
- if supplier is null.- See Also:
Factory
-
asTransformer
public static <I,O> org.apache.commons.collections4.Transformer<I,O> asTransformer(FunctionWithException<I,O,?> function)
Transforms aFunctionWithException
to the one from commons-collections.- Type Parameters:
I
- the input argument type of the functionO
- the result type of the function- Parameters:
function
- theFunctionWithException
to be transformed to the one from commons-collections.- Returns:
- the
transformer
from commons-collections. The ClassCastException and IllegalArgumentException are not wrapped and the other exception are wrapped in a FunctorException. - Throws:
NoClassDefFoundError
- In case the commons-collections4 library is not available.NullPointerException
- if function is null.- See Also:
Transformer
-
asClosure
public static <T> org.apache.commons.collections4.Closure<T> asClosure(ConsumerWithException<T,?> consumer)
Transforms aConsumerWithException
to the one from commons-collections.- Type Parameters:
T
- the type of the input argument for the consumer- Parameters:
consumer
- theConsumerWithException
to be transformed to the one from commons-collections.- Returns:
- the
closure
from commons-collections. The ClassCastException and IllegalArgumentException are not wrapped and the other exception are wrapped in a FunctorException. - Throws:
NoClassDefFoundError
- In case the commons-collections4 library is not available.NullPointerException
- if consumer is null.- See Also:
Closure
-
-