public T getResource() {
        return resource;
    }
<p>Utility class for working with reference-counted {@link SharedResource}s.</p>

<p>Sometimes, you may want a method to return <i>both</i> a resource object <i>and</i>
a {@link ResourceReference} that refers the resource object (for later release of the resource).
Java methods cannot return multiple objects, so this class provides Pair-like functionality
for returning both.</p>

<p>Example usage:</p>
<pre>
    ReferencedResource&lt;MyResource&gt; getResource() {
        final ResourceReference ref = resource.refer();
        return new ReferencedResource(resource, ref);
    }

    void useResource() {
        final ReferencedResource&lt;MyResource&gt; referencedResource = getResource();
        referencedResource.getResource().use();
        referencedResource.getReference().close();
    }
</pre>

<p>This class implements AutoCloseable, so the latter method may also be written as follows:</p>
<pre>
    void useResource() {
        for (final ReferencedResource&lt;MyResource&gt; referencedResource = getResource()) {
            referencedResource.getResource().use();
        }
    }
</pre>

@author bakksjo
jdisc_core/src/main/java/com/yahoo/jdisc/ReferencedResource.java