Class LambdaUtils

java.lang.Object
codechicken.lib.util.LambdaUtils

public class LambdaUtils extends Object
Basically a bunch of lambda helpers.

Created by covers1624 on 1/06/2017.

  • Constructor Details

    • LambdaUtils

      public LambdaUtils()
  • Method Details

    • forEach

      public static <T> boolean forEach(Iterable<T> iterable, Predicate<T> predicate)
      Tests if a predicate holds for all elements of the iterable.
      Type Parameters:
      T - What we are dealing with.
      Parameters:
      iterable - The iterable to test.
      predicate - The predicate.
      Returns:
      True if the predicate holds for all elements in the iterable.
    • forEach

      public static <E> void forEach(E[] elements, Consumer<E> consumer)
      For Each Array lambda support. Because reasons.
      Type Parameters:
      E - The thing!
      Parameters:
      elements - What to loop.
      consumer - Lambda.
    • checkArgument

      public static <E> void checkArgument(E argument, String log, Predicate<E> predicate)
      Provides a predicate callback for checking a condition.
      Type Parameters:
      E - The thing.
      Parameters:
      argument - The thing we are checking.
      log - What the reason for the predicate failing is.
      predicate - The predicate callback.
    • tryQuietly

      public static void tryQuietly(net.covers1624.quack.util.SneakyUtils.ThrowingRunnable<Throwable> runnable)
      Try's the operation quietly, disposing of any exception thrown. Useful for things where you literally don't care what the result is.
      Parameters:
      runnable - The thing to run.
    • tryOrNull

      public static <T> T tryOrNull(Supplier<T> supplier)
      Attempts to run the supplier, returns null on an exception.
      Type Parameters:
      T - The Generic type.
      Parameters:
      supplier - The supplier to run.
      Returns:
      The thing from the supplier.