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
ARunnable
that 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 interface
whose 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 IThrowingRunnable
of(IThrowingRunnable runnable)
Returns the given Runnable, for improved variable inference.default void
run()
void
tryRun()
Performs this operation.
-
-
-
Method Detail
-
tryRun
void tryRun() throws Exception
Performs 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.
-
-