public static <T, R> Function<T, R> doIf(final Predicate<T> condition,
                                             final CheckedFunction<T, R> trueFunction,
                                             final CheckedFunction<T, R> falseFunction) {
        return t -> {
            try {
                if (condition.test(t)) {
                    return trueFunction.apply(t);
                }
                return falseFunction.apply(t);
            } catch (final Throwable e) {
                LoggingUtils.warn(LOGGER, e);
                try {
                    return falseFunction.apply(t);
                } catch (final Throwable ex) {
                    throw new IllegalArgumentException(ex.getMessage());
                }
            }
        };
    }
Conditional function function.

@param <T>           the type parameter
@param <R>           the type parameter
@param condition     the condition
@param trueFunction  the true function
@param falseFunction the false function
@return the function
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/function/FunctionUtils.java