/** * Converts checked exceptions to unchecked based on the {@code Predicate} interface. * <p> * This wraps the specified predicate returning an instance that handles checked exceptions. * If a checked exception is thrown it is converted to an {@link UncheckedIOException} * or {@link RuntimeException} as appropriate. * * @param <T> the type of the predicate * @param predicate the predicate to be decorated * @return the predicate instance that handles checked exceptions */ public static <T> Predicate<T> predicate(CheckedPredicate<T> predicate) { return (t) -> { try { return predicate.test(t); } catch (Throwable ex) { throw propagate(ex); } }; }