@FunctionalInterface
@Generated(value="uk.kludje.annotation.processor.UncheckedFunctionalInterfaceProcessor")
public interface UIntSupplier
extends java.util.function.IntSupplier
int $getAsInt() throws Throwable USING A LAMBDA; INVOKE int getAsInt().
A functional interface for handling checked exceptions. See parent type for interface intent.
int getAsInt() invokes int $getAsInt()
and throws anything thrown by int $getAsInt().
General example using java.lang.Runnable that reduces 11 lines to a single line.
Call someMethodThatThrowsException in throwsNothing:
public void someMethodThatThrowsException() throws IOException {
// I/O functionality
}
public void throwsNothing(Runnable r) {
r.run();
}
Before:
public void yourMethod() throws IOException {
try {
throwsNothing(() -> {
try {
someMethodThatThrowsException();
} catch (IOException e) {
throw new SomeWrapperException(e);
}
});
} catch(SomeWrapperException w) {
throw (IOException) w.getCause();
}
}
After:
public void yourMethod() throws IOException {
throwsNothing((URunnable) this::someMethodThatThrowsException);
}
Method public static UIntSupplier asUIntSupplier(UIntSupplier t)
provides a convenience method for manufacturing types as an alternative to casting.
| Modifier and Type | Method and Description |
|---|---|
int |
$getAsInt() |
static UIntSupplier |
asUIntSupplier(UIntSupplier t) |
default int |
getAsInt() |
default int getAsInt()
getAsInt in interface java.util.function.IntSupplierint $getAsInt()
throws java.lang.Throwable
java.lang.Throwablestatic UIntSupplier asUIntSupplier(UIntSupplier t)