类 SneakyUtils

java.lang.Object
committee.nova.mods.avaritia.api.util.SneakyUtils

public class SneakyUtils extends Object
SneakyUtils
  • 构造器详细资料

    • SneakyUtils

      public SneakyUtils()
  • 方法详细资料

    • none

      public static Runnable none()
      Returns a Runnable that does nothing.
      返回:
      The runnable.
    • nullC

      public static <T> Callable<T> nullC()
      Returns a Callable that always returns null when executed.
      返回:
      The callable.
    • nullS

      public static <T> Supplier<T> nullS()
      Returns a Supplier that always returns null when executed.
      返回:
      The callable.
    • nullCons

      public static <T> Consumer<T> nullCons()
      Returns a Consumer that does nothing when executed.
      返回:
      The consumer.
    • trueP

      public static <T> Predicate<T> trueP()
      Returns a Predicate that always passes.
      返回:
      The Predicate.
    • falseP

      public static <T> Predicate<T> falseP()
      Returns a Predicate that always fails.
      返回:
      The Predicate.
    • first

      public static <T> BinaryOperator<T> first()
      A BinaryOperator which always resolves to the left-hand element.
      返回:
      The BinaryOperator.
    • last

      public static <T> BinaryOperator<T> last()
      A BinaryOperator which always resolves to the right-hand element.
      返回:
      The BinaryOperator.
    • concat

      public static Runnable concat(Runnable a, Runnable b)
      Concatenates two Runnables.
      参数:
      a - The First Runnable to execute.
      b - The Second Runnable to execute.
      返回:
      The Concatenated Runnable.
    • notPossible

      public static Supplier<SneakyUtils.NotPossibleException> notPossible()
      Returns a Supplier for a NotPossibleException.

      Useful for Optional instance assertions.

      返回:
      The Supplier.
    • sneaky

      public static void sneaky(SneakyUtils.ThrowingRunnable<Throwable> tr)
      Executes the given ThrowingRunnable, rethrowing any exceptions produced by the runnable as Unchecked(as seen by the compiler.)
      参数:
      tr - The ThrowingRunnable.
    • sneak

      public static Runnable sneak(SneakyUtils.ThrowingRunnable<Throwable> tr)
      Wraps a ThrowingRunnable to a Runnable. See sneaky(ThrowingRunnable) for info.
      参数:
      tr - The ThrowingRunnable to wrap.
      返回:
      The wrapped runnable.
    • sneak

      public static <T> Consumer<T> sneak(SneakyUtils.ThrowingConsumer<T,Throwable> cons)
      Wraps a ThrowingConsumer to a Consumer Rethrowing any exceptions produced by the ThrowingConsumer as unchecked(as seen by the compiler.)
      参数:
      cons - The ThrowingConsumer to wrap.
      返回:
      The wrapped Consumer.
    • sneaky

      public static <T> T sneaky(SneakyUtils.ThrowingSupplier<T,Throwable> sup)
      Executes the given ThrowingRunnable, rethrowing any exceptions produced by the runnable as Unchecked(as seen by the compiler.)
      参数:
      sup - The ThrowingSupplier.
      返回:
      The return result of the ThrowingSupplier.
    • sneak

      public static <T> Supplier<T> sneak(SneakyUtils.ThrowingSupplier<T,Throwable> sup)
      Wraps a ThrowingSupplier to a Supplier Rethrowing any exceptions produced by the ThrowingSupplier as unchecked(as seen by the compiler.)
      参数:
      sup - The ThrowingSupplier to wrap.
      返回:
      The wrapped Supplier.
    • sneak

      public static <T, R> Function<T,R> sneak(SneakyUtils.ThrowingFunction<T,R,Throwable> tf)
      Wraps a ThrowingFunction to a Function Rethrowing any exceptions produced by the ThrowingFunction as unchecked(as seen by the compiler.)
      参数:
      tf - The ThrowingFunction to wrap.
      返回:
      The wrapped Function.
    • unsafeCast

      @Nullable @Contract("null->null;!null->!null") public static <T> T unsafeCast(@Nullable @Nullable Object object)
    • throwUnchecked

      public static <T extends Throwable> void throwUnchecked(Throwable t) throws T
      Throws an exception without compiler warnings.
      抛出:
      T extends Throwable