Class 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 Detail

      • asPredicate

        public static <T> org.apache.commons.collections4.Predicate<T> asPredicate​(PredicateWithException<T,?> predicate)
        Transforms a PredicateWithException to the one from commons-collections.
        Type Parameters:
        T - the type of the input argument for the predicate
        Parameters:
        predicate - the PredicateWithException 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 a SupplierWithException to the one from commons-collections.
        Type Parameters:
        T - the type of the result of the supplier
        Parameters:
        supplier - the SupplierWithException 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 a FunctionWithException to the one from commons-collections.
        Type Parameters:
        I - the input argument type of the function
        O - the result type of the function
        Parameters:
        function - the FunctionWithException 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 a ConsumerWithException to the one from commons-collections.
        Type Parameters:
        T - the type of the input argument for the consumer
        Parameters:
        consumer - the ConsumerWithException 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