Class SoftResource.ResourceHolder<T extends @Nullable Object>

java.lang.Object
com.dua3.utility.io.SoftResource.ResourceHolder<T>
Type Parameters:
T - the generic resource type
All Implemented Interfaces:
AutoCloseable
Enclosing class:
SoftResource<T>

public static final class SoftResource.ResourceHolder<T extends @Nullable Object> extends Object implements AutoCloseable
Helper class to prevent the resource from being garbage collected.
  • Method Details

    • get

      public T get()
      Get the resource being held.
      Returns:
      the resource
    • getSoftResource

      public SoftResource<T> getSoftResource()
      Get the SoftResource instance this holder belongs to.
      Returns:
      the soft resource
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • toString

      public String toString()
      Overrides:
      toString in class Object