public class SneakyUtils
extends java.lang.Object
Created by covers1624 on 13/1/21.
| Modifier and Type | Class and Description |
|---|---|
static class |
SneakyUtils.NotPossibleException |
static interface |
SneakyUtils.ThrowingConsumer<T,E extends java.lang.Throwable> |
static interface |
SneakyUtils.ThrowingFunction<T,R,E extends java.lang.Throwable> |
static interface |
SneakyUtils.ThrowingRunnable<E extends java.lang.Throwable> |
static interface |
SneakyUtils.ThrowingSupplier<T,E extends java.lang.Throwable> |
| Constructor and Description |
|---|
SneakyUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.Runnable |
concat(java.lang.Runnable a,
java.lang.Runnable b)
Concatenates two
Runnables. |
static <T> java.util.function.Predicate<T> |
falseP()
Returns a Predicate that always fails.
|
static <T> java.util.function.BinaryOperator<T> |
first()
A BinaryOperator which always resolves to the left-hand element.
|
static <T> java.util.function.BinaryOperator<T> |
last()
A BinaryOperator which always resolves to the right-hand element.
|
static java.lang.Runnable |
none()
Returns a Runnable that does nothing.
|
static java.util.function.Supplier<SneakyUtils.NotPossibleException> |
notPossible()
Returns a Supplier for a NotPossibleException.
|
static <T> java.util.concurrent.Callable<T> |
nullC()
Returns a Callable that always returns null when executed.
|
static <T> java.util.function.Consumer<T> |
nullCons()
Returns a Consumer that does nothing when executed.
|
static <T> java.util.function.Supplier<T> |
nullS()
Returns a Supplier that always returns null when executed.
|
static <T> java.util.function.Consumer<T> |
sneak(SneakyUtils.ThrowingConsumer<T,java.lang.Throwable> cons)
Wraps a ThrowingConsumer to a
Consumer
Rethrowing any exceptions produced by the ThrowingConsumer
as unchecked(as seen by the compiler.) |
static <T,R> java.util.function.Function<T,R> |
sneak(SneakyUtils.ThrowingFunction<T,R,java.lang.Throwable> tf)
Wraps a ThrowingFunction to a
Function
Rethrowing any exceptions produced by the ThrowingFunction
as unchecked(as seen by the compiler.) |
static java.lang.Runnable |
sneak(SneakyUtils.ThrowingRunnable<java.lang.Throwable> tr)
Wraps a ThrowingRunnable to a
Runnable. |
static <T> java.util.function.Supplier<T> |
sneak(SneakyUtils.ThrowingSupplier<T,java.lang.Throwable> sup)
Wraps a ThrowingSupplier to a
Supplier
Rethrowing any exceptions produced by the ThrowingSupplier
as unchecked(as seen by the compiler.) |
static void |
sneaky(SneakyUtils.ThrowingRunnable<java.lang.Throwable> tr)
Executes the given ThrowingRunnable, rethrowing any exceptions
produced by the runnable as Unchecked(as seen by the compiler.)
|
static <T> T |
sneaky(SneakyUtils.ThrowingSupplier<T,java.lang.Throwable> sup)
Executes the given ThrowingRunnable, rethrowing any exceptions
produced by the runnable as Unchecked(as seen by the compiler.)
|
static <T extends java.lang.Throwable> |
throwUnchecked(java.lang.Throwable t)
Throws an exception without compiler warnings.
|
static <T> java.util.function.Predicate<T> |
trueP()
Returns a Predicate that always passes.
|
static <T> T |
unsafeCast(java.lang.Object object) |
public static java.lang.Runnable none()
public static <T> java.util.concurrent.Callable<T> nullC()
public static <T> java.util.function.Supplier<T> nullS()
public static <T> java.util.function.Consumer<T> nullCons()
public static <T> java.util.function.Predicate<T> trueP()
public static <T> java.util.function.Predicate<T> falseP()
public static <T> java.util.function.BinaryOperator<T> first()
public static <T> java.util.function.BinaryOperator<T> last()
public static java.lang.Runnable concat(java.lang.Runnable a,
java.lang.Runnable b)
Runnables.a - The First Runnable to execute.b - The Second Runnable to execute.Runnable.public static java.util.function.Supplier<SneakyUtils.NotPossibleException> notPossible()
Useful for Optional instance assertions.
public static void sneaky(SneakyUtils.ThrowingRunnable<java.lang.Throwable> tr)
tr - The ThrowingRunnable.public static java.lang.Runnable sneak(SneakyUtils.ThrowingRunnable<java.lang.Throwable> tr)
Runnable.
See sneaky(ThrowingRunnable) for info.tr - The ThrowingRunnable to wrap.public static <T> java.util.function.Consumer<T> sneak(SneakyUtils.ThrowingConsumer<T,java.lang.Throwable> cons)
Consumer
Rethrowing any exceptions produced by the ThrowingConsumer
as unchecked(as seen by the compiler.)cons - The ThrowingConsumer to wrap.public static <T> T sneaky(SneakyUtils.ThrowingSupplier<T,java.lang.Throwable> sup)
sup - The ThrowingSupplier.public static <T> java.util.function.Supplier<T> sneak(SneakyUtils.ThrowingSupplier<T,java.lang.Throwable> sup)
Supplier
Rethrowing any exceptions produced by the ThrowingSupplier
as unchecked(as seen by the compiler.)sup - The ThrowingSupplier to wrap.public static <T,R> java.util.function.Function<T,R> sneak(SneakyUtils.ThrowingFunction<T,R,java.lang.Throwable> tf)
Function
Rethrowing any exceptions produced by the ThrowingFunction
as unchecked(as seen by the compiler.)tf - The ThrowingFunction to wrap.public static <T> T unsafeCast(java.lang.Object object)
public static <T extends java.lang.Throwable> void throwUnchecked(java.lang.Throwable t)
throws T extends java.lang.Throwable
T extends java.lang.Throwable