Package pl.matsuo.core.util.function
Class FunctionalUtil
java.lang.Object
pl.matsuo.core.util.function.FunctionalUtil
Functional programming utils.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classObjects provide access to some element. -
Field Summary
FieldsModifier and TypeFieldDescriptionConsumer of exception that logs error.Consumer that throws RuntimeException with passed exception as root cause. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <E> FunctionalUtil.AccessProvider<E>Create access provider from field on object.static <E> FunctionalUtil.AccessProvider<E>Create access provider from getter/setter pair.static <E> List<E>collectList(Supplier<Boolean> condition, Supplier<E> getter) Collect elements returned by getter until condition is true;static <E> Consumer<E>Create consumer that invokes list of inner consumers.static <E> EInvoke ifTrue or ifFalse depending on what parameter.static voidignoreEx(ThrowingExceptionsRunnable throwsExceptions) Invoke runnable and ignore exceptions.static <E> EignoreEx(ThrowingExceptionsSupplier<E> throwsExceptions) Invoke supplier and return null on exception.static voidprocessEx(ThrowingExceptionsRunnable throwsExceptions, Consumer<Exception> processEx) Invoke runnable with exception handler.static <E> EprocessEx(ThrowingExceptionsSupplier<E> throwsExceptions, Function<Exception, E> processEx) Invoke supplier with exception handler.static voidRepeat runnable invocations until condition is true.static voidruntimeEx(ThrowingExceptionsRunnable throwsExceptions) Invoke runnable and throw RuntimeException on exception.static voidruntimeEx(ThrowingExceptionsRunnable throwsExceptions, Consumer<Exception> processEx) Invoke runnable with exception handler.static <E> EruntimeEx(ThrowingExceptionsSupplier<E> throwsExceptions) Invoke supplier and throw RuntimeException on exception.static <E,F> F Return function invocation result with object as parameter.static <E,F> void with(E object, F object2, BiConsumer<E, F> invoke) Invoke consumer with two objects as parameters.static <E> EInvoke consumer with object as parameter.
-
Field Details
-
ignoringExConsumer
Consumer of exception that logs error. -
runtimeExConsumer
Consumer that throws RuntimeException with passed exception as root cause.
-
-
Constructor Details
-
FunctionalUtil
public FunctionalUtil()
-
-
Method Details
-
access
Create access provider from getter/setter pair. -
access
Create access provider from field on object. -
with
Invoke consumer with object as parameter. -
transform
Return function invocation result with object as parameter. -
with
Invoke consumer with two objects as parameters. -
ignoreEx
Invoke supplier and return null on exception. -
ignoreEx
Invoke runnable and ignore exceptions. -
runtimeEx
Invoke supplier and throw RuntimeException on exception. -
runtimeEx
Invoke runnable and throw RuntimeException on exception. -
runtimeEx
public static void runtimeEx(ThrowingExceptionsRunnable throwsExceptions, Consumer<Exception> processEx) Invoke runnable with exception handler. -
processEx
public static <E> E processEx(ThrowingExceptionsSupplier<E> throwsExceptions, Function<Exception, E> processEx) Invoke supplier with exception handler. -
processEx
public static void processEx(ThrowingExceptionsRunnable throwsExceptions, Consumer<Exception> processEx) Invoke runnable with exception handler. -
compose
Create consumer that invokes list of inner consumers. -
either
Invoke ifTrue or ifFalse depending on what parameter. -
repeat
Repeat runnable invocations until condition is true. -
collectList
Collect elements returned by getter until condition is true;
-