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

net.yetamine.lang.closeables.AutoCloseableResource Maven / Gradle / Ivy

There is a newer version: 1.3.0
Show newest version
package net.yetamine.lang.closeables;

/**
 * A generic interface for adapting resource-like objects that do not implement
 * {@link AutoCloseable} (yet) and therefore try-with-resources can't manage
 * them.
 *
 * @param 
 *            the type of the adapted resource
 * @param 
 *            the type of the exception that the {@link AutoCloseable#close()}
 *            method may throw for this resource
 */
public interface AutoCloseableResource extends AutoCloseable {

    /**
     * Provides the adapted resource.
     *
     * 

* Implementations should not return {@code null}, or at least until closing * the resource; after closing the resource, implementations should throw an * exception (like {@link IllegalStateException}) rather than returning * {@code null}. A lightweight implementation may keep returning always the * same result, regardless the state. * * @return the adapted resource */ T resource(); /** * @see java.lang.AutoCloseable#close() */ void close() throws X; }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy