Package codechicken.lib.util
Class LambdaUtils
java.lang.Object
codechicken.lib.util.LambdaUtils
Basically a bunch of lambda helpers.
Created by covers1624 on 1/06/2017.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <E> voidcheckArgument(E argument, String log, Predicate<E> predicate) Provides a predicate callback for checking a condition.static <E> voidFor Each Array lambda support.static <T> booleanTests if a predicate holds for all elements of the iterable.static <T> TAttempts to run the supplier, returns null on an exception.static voidtryQuietly(net.covers1624.quack.util.SneakyUtils.ThrowingRunnable<Throwable> runnable) Try's the operation quietly, disposing of any exception thrown.
-
Constructor Details
-
LambdaUtils
public LambdaUtils()
-
-
Method Details
-
forEach
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
For Each Array lambda support. Because reasons.- Type Parameters:
E- The thing!- Parameters:
elements- What to loop.consumer- Lambda.
-
checkArgument
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
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.
-