Package de.xima.fc.interfaces
Interface IThrowingRunnable
-
- All Superinterfaces:
Runnable
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface IThrowingRunnable extends Runnable
ARunnablethat may throw a checked exception.This interface is designed to provide a common protocol for objects that wish to execute code
This is a
functional interfacewhose functional method istryRun().- Since:
- 8.0.0
- Author:
- XIMA MEDIA GmbH
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static IThrowingRunnableof(IThrowingRunnable runnable)Returns the given Runnable, for improved variable inference.default voidrun()voidtryRun()Performs this operation.
-
-
-
Method Detail
-
tryRun
void tryRun() throws ExceptionPerforms this operation.- Throws:
Exception- When this operation fails.
-
of
static IThrowingRunnable of(IThrowingRunnable runnable)
Returns the given Runnable, for improved variable inference. Sometimes you need to create local variables and assign them to a new lambda. This does not work well with variable inference, as Java cannot infer the type of an anonymous lambda. This utility method lets you write slightly more readable code like this:final var supplier = IThrowingRunnable.of(() -> ...);
- Parameters:
runnable- Runnable to return.- Returns:
- The given consumer.
-
-