/*
 * @author Ranides Atterwim <ranides@gmail.com>
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */
package net.ranides.assira.io;

import java.io.Closeable;
import java.io.IOException;
import net.ranides.assira.functional.CheckedConsumer;
import net.ranides.assira.functional.CheckedSupplier;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public interface IOHandle<T> extends Closeable, CheckedSupplier<T, IOException> {

    static <T> IOHandle<T> shared(CheckedConsumer<T,IOException> close, CheckedSupplier<T,IOException> open) {
        return new IOUtils.SharedHandle<>(close, open);
    }

    static <T> IOHandle<T> shared(CheckedSupplier<T,IOException> open) {
        return new IOUtils.SharedHandle<>(open);
    }
    
    @Override
    void close() throws IOException;

    @Override
    T get() throws IOException;
    
    boolean opened();
    
    
}
