@SuppressWarnings("unchecked")
    public <T extends Closeable> T getResource(Class<T> klass) {
        for (Closeable resource : resources) {
            if (klass.isAssignableFrom(resource.getClass())) {
                return (T) resource;
            }
        }
        return null;
    }
Returns the latest of the tracked resources that implements or
extends the given interface or class.

@param klass interface or class
@return matching resource, or <code>null</code> if not found
tika-core/src/main/java/org/apache/tika/io/TemporaryResources.java