Interface PoolableObject.Reference<X extends Exception>

  • Type Parameters:
    X - The type of exception that can be thrown when resources are released.
    All Superinterfaces:
    AutoCloseable
    Enclosing class:
    PoolableObject<X extends Exception>

    public static interface PoolableObject.Reference<X extends Exception>
    extends AutoCloseable
    A reference to a PoolableObject. If a reference is removed or closed and no more references to the PoolableObject from which it was created remain, the PoolableObject will be returned to the pool it was acquired from. If it is not associated with a pool, its resources will be released instead.
    Author:
    Rob Spoor
    Since:
    2.0
    • Method Detail

      • remove

        void remove()
             throws X extends Exception
        Removes the reference to the PoolableObject from which this reference was created. If no more references remain, the PoolableObject will be returned to the pool it was acquired from. If it is not associated with a pool, its resources will be released called instead.
        Throws:
        X - If the resources could not be released.
        X extends Exception
      • close

        default void close()
                    throws X extends Exception
        Removes the reference to the PoolableObject from which this reference was created. This method is an alias for remove() that allows instances to be used in try-with-resources blocks.
        Specified by:
        close in interface AutoCloseable
        Throws:
        X - If the resources could not be released.
        X extends Exception