public class Lambda extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Lambda.CallableThatThrows<T> |
static interface |
Lambda.FunctionThatThrows<T,R> |
static interface |
Lambda.IteratorWithIndex<T> |
static interface |
Lambda.RunnableThatThrows |
static interface |
Lambda.RunnableThatThrows3Exceptions<A extends Throwable,B extends Throwable,C extends Throwable> |
Modifier and Type | Field and Description |
---|---|
static BiConsumer<Integer,Lambda.RunnableThatThrows> |
repeater
repeats func function limit number of times
|
Modifier and Type | Method and Description |
---|---|
static <T> void |
forEachWithIndex(Iterable<T> iterable,
Lambda.IteratorWithIndex<T> iteratorWithIndex) |
static <A,B,C> Map<B,C> |
mapKeys(Map<A,C> map,
Function<A,B> mapper) |
static <A,B,C> Map<A,C> |
mapValues(Map<A,B> map,
Function<B,C> mapper) |
static <T> Callable<T> |
silent(Lambda.CallableThatThrows<T> functionThatThrows) |
static <T,R> Function<T,R> |
silent(Lambda.FunctionThatThrows<T,R> functionThatThrows) |
static Runnable |
silent(Lambda.RunnableThatThrows functionThatThrows) |
static <T> T |
withLock(Lock lock,
Callable<T> callable)
Execute a callable with lock acquire/release
|
static void |
withLock(Lock lock,
Runnable runnable)
Execute a runnable with lock acquire/release
|
static <T,E1 extends Exception> |
withLockException1(Lock lock,
Callable<T> callable,
Class<E1> exception1Class)
Execute a callable with lock acquire/release, handling one checked exception
|
static <T,E1 extends Exception,E2 extends Exception> |
withLockException2(Lock lock,
Callable<T> callable,
Class<E1> exception1Class,
Class<E2> exception2Class)
Execute a callable with lock acquire/release, handling two checked exceptions
|
static <T,E extends Exception> |
withLockInterruptible(Lock lock,
Callable<T> callable,
E interruptedException)
Execute a callable with lock acquire/release, handling InterruptedException
|
public static final BiConsumer<Integer,Lambda.RunnableThatThrows> repeater
public static void withLock(Lock lock, Runnable runnable)
lock
- the lock to acquirerunnable
- code to executepublic static <T> T withLock(Lock lock, Callable<T> callable)
T
- return typelock
- the lock to acquirecallable
- code to executepublic static <T,E extends Exception> T withLockInterruptible(Lock lock, Callable<T> callable, E interruptedException) throws E extends Exception
T
- return typeE
- wrapper exception typelock
- the lock to acquire interruptiblycallable
- code to executeinterruptedException
- exception which will be used to wrap the InterruptedException (null to use a RuntimeException)E
- when the lock is interruptedE extends Exception
public static <T,E1 extends Exception> T withLockException1(Lock lock, Callable<T> callable, Class<E1> exception1Class) throws E1 extends Exception
T
- return typeE1
- type of checked exceptionlock
- the lock to acquirecallable
- code to executeexception1Class
- the class of the checked exception which will be handledE1
- when this exception occurs in the callableE1 extends Exception
public static <T,E1 extends Exception,E2 extends Exception> T withLockException2(Lock lock, Callable<T> callable, Class<E1> exception1Class, Class<E2> exception2Class) throws E1 extends Exception, E2 extends Exception
T
- return typeE1
- type of the first checked exceptionE2
- type of the second checked exceptionlock
- the lock to acquirecallable
- code to executeexception1Class
- the class of the first checked exception which will be handledexception2Class
- the class of the second checked exception which will be handledE1
- when the first exception type occurs in the callableE2
- when the second exception type occurs in the callableE1 extends Exception
public static <T,R> Function<T,R> silent(Lambda.FunctionThatThrows<T,R> functionThatThrows)
public static <T> Callable<T> silent(Lambda.CallableThatThrows<T> functionThatThrows)
public static Runnable silent(Lambda.RunnableThatThrows functionThatThrows)
public static <T> void forEachWithIndex(Iterable<T> iterable, Lambda.IteratorWithIndex<T> iteratorWithIndex)