Package org.apereo.cas.util.function
Class FunctionUtils
- java.lang.Object
-
- org.apereo.cas.util.function.FunctionUtils
-
public class FunctionUtils extends java.lang.ObjectThis isFunctionUtils.- Since:
- 6.0.0
-
-
Constructor Summary
Constructors Constructor Description FunctionUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <R> voiddoAndHandle(org.jooq.lambda.fi.util.function.CheckedConsumer<R> function)Do and handle.static <R> java.util.function.Consumer<R>doAndHandle(org.jooq.lambda.fi.util.function.CheckedConsumer<R> function, org.jooq.lambda.fi.util.function.CheckedFunction<java.lang.Throwable,R> errorHandler)Do and handle checked consumer.static <T,R>
java.util.function.Function<T,R>doAndHandle(org.jooq.lambda.fi.util.function.CheckedFunction<T,R> function, org.jooq.lambda.fi.util.function.CheckedFunction<java.lang.Throwable,R> errorHandler)Default function function.static <R> RdoAndHandle(org.jooq.lambda.fi.util.function.CheckedSupplier<R> function)Do and handle.static <R> java.util.function.Supplier<R>doAndHandle(org.jooq.lambda.fi.util.function.CheckedSupplier<R> function, org.jooq.lambda.fi.util.function.CheckedFunction<java.lang.Throwable,R> errorHandler)Do and handle supplier.static <T> TdoAndRetry(java.util.List<java.lang.Class<? extends java.lang.Throwable>> clazzes, org.springframework.retry.RetryCallback<T,java.lang.Exception> callback)Do and retry.static <T> TdoAndRetry(org.springframework.retry.RetryCallback<T,java.lang.Exception> callback)Do and retry.static <T> TdoAndReturn(boolean condition, java.util.function.Supplier<T> trueTask, java.util.function.Supplier<T> falseTask)Do and return.static <T> java.util.function.Consumer<T>doIf(boolean condition, java.util.function.Consumer<T> trueFunction)Do if condition holds.static <T> java.util.function.Consumer<T>doIf(boolean condition, java.util.function.Consumer<T> trueFunction, java.util.function.Consumer<T> falseFunction)Do if consumer.static <R> java.util.function.Supplier<R>doIf(boolean condition, java.util.function.Supplier<R> trueFunction, java.util.function.Supplier<R> falseFunction)Do if function.static <T,R>
java.util.function.Function<T,R>doIf(java.util.function.Predicate<java.lang.Object> condition, java.util.function.Supplier<R> trueFunction, java.util.function.Supplier<R> falseFunction)Do if function.static <T,R>
java.util.function.Function<T,R>doIf(java.util.function.Predicate<T> condition, org.jooq.lambda.fi.util.function.CheckedFunction<T,R> trueFunction, org.jooq.lambda.fi.util.function.CheckedFunction<T,R> falseFunction)Conditional function function.static <R> java.util.function.Supplier<R>doIfNotNull(java.lang.Object input, java.util.function.Supplier<R> trueFunction, java.util.function.Supplier<R> falseFunction)Supply if not null supplier.static <T> voiddoIfNotNull(T input, org.jooq.lambda.fi.util.function.CheckedConsumer<T> trueFunction)Do if not null.static <T> voiddoIfNotNull(T input, org.jooq.lambda.fi.util.function.CheckedConsumer<T> trueFunction, org.jooq.lambda.fi.util.function.CheckedConsumer<T> elseFunction)Do if not null.static <R> java.util.function.Supplier<R>doIfNull(java.lang.Object input, java.util.function.Supplier<R> trueFunction, java.util.function.Supplier<R> falseFunction)Supply if null supplier.static voiddoUnchecked(org.jooq.lambda.fi.util.function.CheckedConsumer<java.lang.Object> consumer, java.lang.Object... params)Do unchecked.static <T> TdoUnchecked(org.jooq.lambda.fi.util.function.CheckedSupplier<T> consumer)Do unchecked.static booleandoWithoutThrows(java.util.function.Consumer<java.lang.Object> func, java.lang.Object... params)Do without throws and return status.static voidthrowIf(boolean condition, java.util.function.Supplier<? extends java.lang.RuntimeException> throwable)Throw if.static java.lang.StringthrowIfBlank(java.lang.String value)Throw if value is blank.
-
-
-
Method Detail
-
doIf
public static <T,R> java.util.function.Function<T,R> doIf(java.util.function.Predicate<java.lang.Object> condition, java.util.function.Supplier<R> trueFunction, java.util.function.Supplier<R> falseFunction)Do if function.- Type Parameters:
T- the type parameterR- the type parameter- Parameters:
condition- the conditiontrueFunction- the true functionfalseFunction- the false function- Returns:
- the function
-
doIf
public static <T> java.util.function.Consumer<T> doIf(boolean condition, java.util.function.Consumer<T> trueFunction, java.util.function.Consumer<T> falseFunction)Do if consumer.- Type Parameters:
T- the type parameter- Parameters:
condition- the conditiontrueFunction- the true functionfalseFunction- the false function- Returns:
- the consumer
-
doIf
public static <T> java.util.function.Consumer<T> doIf(boolean condition, java.util.function.Consumer<T> trueFunction)Do if condition holds.- Type Parameters:
T- the type parameter- Parameters:
condition- the conditiontrueFunction- the true function- Returns:
- the consumer
-
doIf
public static <R> java.util.function.Supplier<R> doIf(boolean condition, java.util.function.Supplier<R> trueFunction, java.util.function.Supplier<R> falseFunction)Do if function.- Type Parameters:
R- the type parameter- Parameters:
condition- the conditiontrueFunction- the true functionfalseFunction- the false function- Returns:
- the function
-
doIf
public static <T,R> java.util.function.Function<T,R> doIf(java.util.function.Predicate<T> condition, org.jooq.lambda.fi.util.function.CheckedFunction<T,R> trueFunction, org.jooq.lambda.fi.util.function.CheckedFunction<T,R> falseFunction)Conditional function function.- Type Parameters:
T- the type parameterR- the type parameter- Parameters:
condition- the conditiontrueFunction- the true functionfalseFunction- the false function- Returns:
- the function
-
doIfNotNull
public static <R> java.util.function.Supplier<R> doIfNotNull(java.lang.Object input, java.util.function.Supplier<R> trueFunction, java.util.function.Supplier<R> falseFunction)Supply if not null supplier.- Type Parameters:
R- the type parameter- Parameters:
input- the inputtrueFunction- the true functionfalseFunction- the false function- Returns:
- the supplier
-
doIfNotNull
public static <T> void doIfNotNull(T input, org.jooq.lambda.fi.util.function.CheckedConsumer<T> trueFunction)Do if not null.- Type Parameters:
T- the type parameter- Parameters:
input- the inputtrueFunction- the true function
-
doIfNotNull
public static <T> void doIfNotNull(T input, org.jooq.lambda.fi.util.function.CheckedConsumer<T> trueFunction, org.jooq.lambda.fi.util.function.CheckedConsumer<T> elseFunction)Do if not null.- Type Parameters:
T- the type parameter- Parameters:
input- the inputtrueFunction- the true functionelseFunction- the else function
-
doIfNull
public static <R> java.util.function.Supplier<R> doIfNull(java.lang.Object input, java.util.function.Supplier<R> trueFunction, java.util.function.Supplier<R> falseFunction)Supply if null supplier.- Type Parameters:
R- the type parameter- Parameters:
input- the inputtrueFunction- the true functionfalseFunction- the false function- Returns:
- the supplier
-
doAndHandle
public static <T,R> java.util.function.Function<T,R> doAndHandle(org.jooq.lambda.fi.util.function.CheckedFunction<T,R> function, org.jooq.lambda.fi.util.function.CheckedFunction<java.lang.Throwable,R> errorHandler)Default function function.- Type Parameters:
T- the type parameterR- the type parameter- Parameters:
function- the functionerrorHandler- the error handler- Returns:
- the function
-
doAndHandle
public static <R> java.util.function.Consumer<R> doAndHandle(org.jooq.lambda.fi.util.function.CheckedConsumer<R> function, org.jooq.lambda.fi.util.function.CheckedFunction<java.lang.Throwable,R> errorHandler)Do and handle checked consumer.- Type Parameters:
R- the type parameter- Parameters:
function- the functionerrorHandler- the error handler- Returns:
- the checked consumer
-
doAndHandle
public static <R> R doAndHandle(org.jooq.lambda.fi.util.function.CheckedSupplier<R> function)
Do and handle.- Type Parameters:
R- the type parameter- Parameters:
function- the function- Returns:
- the r
-
doAndHandle
public static <R> void doAndHandle(org.jooq.lambda.fi.util.function.CheckedConsumer<R> function)
Do and handle.- Type Parameters:
R- the type parameter- Parameters:
function- the function
-
doAndHandle
public static <R> java.util.function.Supplier<R> doAndHandle(org.jooq.lambda.fi.util.function.CheckedSupplier<R> function, org.jooq.lambda.fi.util.function.CheckedFunction<java.lang.Throwable,R> errorHandler)Do and handle supplier.- Type Parameters:
R- the type parameter- Parameters:
function- the functionerrorHandler- the error handler- Returns:
- the supplier
-
doWithoutThrows
public static boolean doWithoutThrows(java.util.function.Consumer<java.lang.Object> func, java.lang.Object... params)Do without throws and return status.- Parameters:
func- the funcparams- the params- Returns:
- true /false
-
doUnchecked
public static <T> T doUnchecked(org.jooq.lambda.fi.util.function.CheckedSupplier<T> consumer)
Do unchecked.- Type Parameters:
T- the type parameter- Parameters:
consumer- the consumer- Returns:
- the t
-
doUnchecked
public static void doUnchecked(org.jooq.lambda.fi.util.function.CheckedConsumer<java.lang.Object> consumer, java.lang.Object... params)Do unchecked.- Parameters:
consumer- the consumerparams- the params
-
doAndRetry
public static <T> T doAndRetry(org.springframework.retry.RetryCallback<T,java.lang.Exception> callback)
Do and retry.- Type Parameters:
T- the type parameter- Parameters:
callback- the callback- Returns:
- the t
-
doAndRetry
public static <T> T doAndRetry(java.util.List<java.lang.Class<? extends java.lang.Throwable>> clazzes, org.springframework.retry.RetryCallback<T,java.lang.Exception> callback)Do and retry.- Type Parameters:
T- the type parameter- Parameters:
clazzes- the classified clazzescallback- the callback- Returns:
- the t
-
throwIfBlank
public static java.lang.String throwIfBlank(java.lang.String value)
Throw if value is blank.- Parameters:
value- the value- Returns:
- the value
-
throwIf
public static void throwIf(boolean condition, java.util.function.Supplier<? extends java.lang.RuntimeException> throwable)Throw if.- Parameters:
condition- the conditionthrowable- the throwable
-
doAndReturn
public static <T> T doAndReturn(boolean condition, java.util.function.Supplier<T> trueTask, java.util.function.Supplier<T> falseTask)Do and return.- Type Parameters:
T- the type parameter- Parameters:
condition- the conditiontrueTask- the true taskfalseTask- the false task- Returns:
- the ticket
-
-