com.github.vkorobkov.jfixtures.util.WithResource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jfixtures Show documentation
Show all versions of jfixtures Show documentation
Easy test data creator for SQL databases
package com.github.vkorobkov.jfixtures.util;
import lombok.SneakyThrows;
import java.util.function.Function;
public final class WithResource {
private WithResource() {
}
@SneakyThrows
public static TResult touch(
ThrowingSupplier resourceSupplier,
Function callback) {
try (TResource resource = resourceSupplier.get()) {
return callback.apply(resource);
}
}
public interface ThrowingSupplier {
T get() throws Exception;
}
}