Package com.github.phantomthief.util
Class MoreFunctions
- java.lang.Object
-
- com.github.phantomthief.util.MoreFunctions
-
public final class MoreFunctions extends Object
- Author:
- w.vela
-
-
Constructor Summary
Constructors Constructor Description MoreFunctions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,R>
Rcatching(ThrowableFunction<T,R,Exception> function, T t)static <T,R,X extends Throwable>
Rcatching(ThrowableFunction<T,R,Exception> function, T t, ThrowableConsumer<Throwable,X> exceptionHandler)static <R> Rcatching(Callable<R> callable)static <R,X extends Throwable>
Rcatching(Callable<R> callable, ThrowableConsumer<Throwable,X> exceptionHandler)static <R> Optional<R>catchingOptional(Callable<R> callable)static <K,V>
Consumer<Map.Entry<K,V>>consumerKv(BiConsumer<K,V> func)static <K,V>
Predicate<Map.Entry<K,V>>filterKv(BiPredicate<K,V> func)static <K,V,T>
Function<Map.Entry<K,V>,T>mapKv(BiFunction<K,V,T> func)static <X extends Exception>
voidrunCatching(ThrowableRunnable<X> callable)static <X extends Throwable>
voidrunParallel(ForkJoinPool pool, ThrowableRunnable<X> func)static <X extends Exception>
voidrunThrowing(ThrowableRunnable<X> callable)static <X extends Throwable>
voidrunWithThreadName(Function<String,String> name, ThrowableRunnable<X> func)static <R,X extends Throwable>
RsupplyParallel(ForkJoinPool pool, ThrowableSupplier<R,X> func)mainly use forBaseStream.parallel()with specific thread pool see https://stackoverflow.com/questions/21163108/custom-thread-pool-in-java-8-parallel-streamstatic <X extends Throwable,T>
TsupplyWithThreadName(Function<String,String> name, ThrowableSupplier<T,X> func)static <T,R>
Rthrowing(ThrowableFunction<T,R,Exception> function, T t)static <R> Rthrowing(Callable<R> callable)
-
-
-
Method Detail
-
catching
public static <R> R catching(Callable<R> callable)
-
runCatching
public static <X extends Exception> void runCatching(ThrowableRunnable<X> callable)
-
throwing
public static <R> R throwing(Callable<R> callable)
-
runThrowing
public static <X extends Exception> void runThrowing(ThrowableRunnable<X> callable)
-
catching
public static <R,X extends Throwable> R catching(Callable<R> callable, ThrowableConsumer<Throwable,X> exceptionHandler) throws X extends Throwable
- Throws:
X extends Throwable
-
catching
public static <T,R> R catching(ThrowableFunction<T,R,Exception> function, T t)
-
throwing
public static <T,R> R throwing(ThrowableFunction<T,R,Exception> function, T t)
-
catching
public static <T,R,X extends Throwable> R catching(ThrowableFunction<T,R,Exception> function, T t, ThrowableConsumer<Throwable,X> exceptionHandler) throws X extends Throwable
- Throws:
X extends Throwable
-
runParallel
public static <X extends Throwable> void runParallel(ForkJoinPool pool, ThrowableRunnable<X> func) throws X extends Throwable
- Throws:
X extends Throwable- See Also:
supplyParallel(ForkJoinPool, ThrowableSupplier)
-
supplyParallel
public static <R,X extends Throwable> R supplyParallel(ForkJoinPool pool, ThrowableSupplier<R,X> func) throws X extends Throwable
mainly use forBaseStream.parallel()with specific thread pool see https://stackoverflow.com/questions/21163108/custom-thread-pool-in-java-8-parallel-stream- Throws:
X extends Throwable
-
runWithThreadName
public static <X extends Throwable> void runWithThreadName(@Nonnull Function<String,String> name, @Nonnull ThrowableRunnable<X> func) throws X extends Throwable
- Throws:
X extends Throwable
-
supplyWithThreadName
public static <X extends Throwable,T> T supplyWithThreadName(@Nonnull Function<String,String> name, @Nonnull ThrowableSupplier<T,X> func) throws X extends Throwable
- Throws:
X extends Throwable
-
mapKv
public static <K,V,T> Function<Map.Entry<K,V>,T> mapKv(BiFunction<K,V,T> func)
-
filterKv
public static <K,V> Predicate<Map.Entry<K,V>> filterKv(BiPredicate<K,V> func)
-
consumerKv
public static <K,V> Consumer<Map.Entry<K,V>> consumerKv(BiConsumer<K,V> func)
-
-