Class FunctionUtils


  • public class FunctionUtils
    extends java.lang.Object
    This is FunctionUtils.
    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> void doAndHandle​(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> R doAndHandle​(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> 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.
      static <T> T doAndRetry​(org.springframework.retry.RetryCallback<T,​java.lang.Exception> callback)
      Do and retry.
      static <T> T doAndReturn​(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> void doIfNotNull​(T input, org.jooq.lambda.fi.util.function.CheckedConsumer<T> trueFunction)
      Do if not null.
      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.
      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 void doUnchecked​(org.jooq.lambda.fi.util.function.CheckedConsumer<java.lang.Object> consumer, java.lang.Object... params)
      Do unchecked.
      static <T> T doUnchecked​(org.jooq.lambda.fi.util.function.CheckedSupplier<T> consumer)
      Do unchecked.
      static boolean doWithoutThrows​(java.util.function.Consumer<java.lang.Object> func, java.lang.Object... params)
      Do without throws and return status.
      static void throwIf​(boolean condition, java.util.function.Supplier<? extends java.lang.RuntimeException> throwable)
      Throw if.
      static java.lang.String throwIfBlank​(java.lang.String value)
      Throw if value is blank.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FunctionUtils

        public FunctionUtils()
    • 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 parameter
        R - the type parameter
        Parameters:
        condition - the condition
        trueFunction - the true function
        falseFunction - 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 condition
        trueFunction - the true function
        falseFunction - 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 condition
        trueFunction - 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 condition
        trueFunction - the true function
        falseFunction - 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 parameter
        R - the type parameter
        Parameters:
        condition - the condition
        trueFunction - the true function
        falseFunction - 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 input
        trueFunction - the true function
        falseFunction - 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 input
        trueFunction - 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 input
        trueFunction - the true function
        elseFunction - 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 input
        trueFunction - the true function
        falseFunction - 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 parameter
        R - the type parameter
        Parameters:
        function - the function
        errorHandler - 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 function
        errorHandler - 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 function
        errorHandler - 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 func
        params - 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 consumer
        params - 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 clazzes
        callback - 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 condition
        throwable - 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 condition
        trueTask - the true task
        falseTask - the false task
        Returns:
        the ticket