Package org.apache.camel.util.function
Class ThrowingHelper
java.lang.Object
org.apache.camel.util.function.ThrowingHelper
-
Method Summary
Modifier and TypeMethodDescriptionapplyIfNotEmpty
(I value, ThrowingFunction<I, R, T> function) Tests whether the value is not null, an empty string, an empty collection or a map and transform it using the given function.static <I,
R, T extends Throwable>
RapplyIfNotEmpty
(I value, ThrowingFunction<I, R, T> consumer, Supplier<R> orElse) Tests whether the value is not null, an empty string, an empty collection or a map and transform it using the given function.static <I1,
I2, T extends Throwable>
BiConsumer<I1,I2> wrapAsBiConsumer
(ThrowingBiConsumer<I1, I2, T> consumer) Wrap aThrowingBiConsumer
to a standardBiConsumer
by throwing aRuntimeException
in case of an exception is thrown by the delegated consumer.wrapAsConsumer
(ThrowingConsumer<I, T> consumer) Wrap aThrowingConsumer
to a standardConsumer
by throwing aRuntimeException
in case of an exception is thrown by the delegated consumer.wrapAsFunction
(ThrowingFunction<I, R, T> function) Wrap aThrowingFunction
to a standardFunction
by throwing aRuntimeException
in case of an exception is thrown by the delegated function.wrapAsSupplier
(ThrowingSupplier<V, T> supplier) Wrap aThrowingSupplier
to a standardSuppliers
by throwing aRuntimeException
in case of an exception is thrown by the delegated supplier.
-
Method Details
-
wrapAsSupplier
Wrap aThrowingSupplier
to a standardSuppliers
by throwing aRuntimeException
in case of an exception is thrown by the delegated supplier. -
wrapAsConsumer
Wrap aThrowingConsumer
to a standardConsumer
by throwing aRuntimeException
in case of an exception is thrown by the delegated consumer. -
wrapAsBiConsumer
public static <I1,I2, BiConsumer<I1,T extends Throwable> I2> wrapAsBiConsumer(ThrowingBiConsumer<I1, I2, T> consumer) Wrap aThrowingBiConsumer
to a standardBiConsumer
by throwing aRuntimeException
in case of an exception is thrown by the delegated consumer. -
wrapAsFunction
public static <I,R, Function<I,T extends Throwable> R> wrapAsFunction(ThrowingFunction<I, R, T> function) Wrap aThrowingFunction
to a standardFunction
by throwing aRuntimeException
in case of an exception is thrown by the delegated function. -
applyIfNotEmpty
public static <I,R, Optional<R> applyIfNotEmptyT extends Throwable> (I value, ThrowingFunction<I, R, throws TT> function) Tests whether the value is not null, an empty string, an empty collection or a map and transform it using the given function.- Parameters:
value
- the value, if its a String it will be tested for text length as wellfunction
- the function to be executed against value if not empty- Throws:
T extends Throwable
-
applyIfNotEmpty
public static <I,R, R applyIfNotEmptyT extends Throwable> (I value, ThrowingFunction<I, R, throws TT> consumer, Supplier<R> orElse) Tests whether the value is not null, an empty string, an empty collection or a map and transform it using the given function.- Parameters:
value
- the value, if its a String it will be tested for text length as wellconsumer
- the function to be executed against value if not emptyorElse
- the supplier to use to retrieve a result if the given value is empty- Throws:
T extends Throwable
-