public class Sneaky
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Sneaky.SneakyConsumer<T> |
static interface |
Sneaky.SneakyFunction<T,R> |
static interface |
Sneaky.SneakyRunnable |
static interface |
Sneaky.SneakySupplier<T> |
| Constructor and Description |
|---|
Sneaky() |
| Modifier and Type | Method and Description |
|---|---|
static <T extends java.lang.Throwable> |
fake(java.lang.Class<T> exceptionType)
Fake throw an exception to have to declare it in the method signature.
|
static void |
sneak(Sneaky.SneakyRunnable runnable)
Deprecated.
|
static <O> O |
sneak(Sneaky.SneakySupplier<O> supplier)
Deprecated.
|
static void |
sneak(java.lang.Throwable t)
Throw a throwable without having to declare it in the method signature.
|
<T> java.util.function.Consumer<T> |
toConsumer(Sneaky.SneakyConsumer<T> sneakyConsumer)
Turn a sneaky consumer into a regular consumer.
|
<T,R> java.util.function.Function<T,R> |
toFunction(Sneaky.SneakyFunction<T,R> sneakyFunction)
Turn a sneaky function into a regular function.
|
java.lang.Runnable |
toRunnable(Sneaky.SneakyRunnable sneakyRunnable)
Turn a sneaky runnable into a regular runnable.
|
<T> java.util.function.Supplier<T> |
toSupplier(Sneaky.SneakySupplier<T> sneakySupplier)
Turn a sneaky supplier into a regular supplier.
|
static <T> T |
unsafeCast(java.lang.Object object)
Cast an object to any type without any checks.
|
public static <T extends java.lang.Throwable> void fake(java.lang.Class<T> exceptionType)
throws T extends java.lang.Throwable
sneak(java.lang.Throwable)T - The type of the exceptionexceptionType - The type of the exception to fake throwT - The exceptionT extends java.lang.Throwablepublic static void sneak(java.lang.Throwable t)
t - The throwable to throwpublic static <T> T unsafeCast(java.lang.Object object)
ClassCastExceptions at runtime if the object is not of the expected type.T - The type to cast the object toobject - The object to cast@Deprecated @ApiStatus.ScheduledForRemoval public static void sneak(Sneaky.SneakyRunnable runnable)
Sneaky.SneakyRunnable.tryRun() instead.@Deprecated @ApiStatus.ScheduledForRemoval public static <O> O sneak(Sneaky.SneakySupplier<O> supplier)
Sneaky.SneakySupplier.tryGet() instead.public java.lang.Runnable toRunnable(Sneaky.SneakyRunnable sneakyRunnable)
sneakyRunnable - The sneaky runnable to convertSneaky.SneakyRunnable.toRunnable()public <T> java.util.function.Supplier<T> toSupplier(Sneaky.SneakySupplier<T> sneakySupplier)
T - The type of the value returned by the suppliersneakySupplier - The sneaky supplier to convertSneaky.SneakySupplier.toSupplier()public <T> java.util.function.Consumer<T> toConsumer(Sneaky.SneakyConsumer<T> sneakyConsumer)
T - The type of the value accepted by the consumersneakyConsumer - The sneaky consumer to convertSneaky.SneakyConsumer.toConsumer()public <T,R> java.util.function.Function<T,R> toFunction(Sneaky.SneakyFunction<T,R> sneakyFunction)
T - The type of the input to the functionR - The type of the result of the functionsneakyFunction - The sneaky function to convertSneaky.SneakyFunction.toFunction()