All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.vkorobkov.jfixtures.util.WithResource Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy