Interface ObjectPool.Lease<O>

Type Parameters:
O - The object type.
All Superinterfaces:
AutoCloseable, Closeable
Enclosing interface:
ObjectPool<O>

public static interface ObjectPool.Lease<O> extends Closeable
A lease for an object (obtained via get()); working with the object is only permitted before close().
Author:
Christian Kohlschütter
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Terminates the validity of this lease.
    void
    Marks the leased object as discarded, potentially preventing it from being reused in the object pool.
    get()
    Returns the leased object, potentially null when discarded/closed.
  • Method Details

    • get

      O get()
      Returns the leased object, potentially null when discarded/closed.
      Returns:
      The object, or null.
    • close

      void close()
      Terminates the validity of this lease. Unless discarded via discard(), the object may end up back in the object pool it was leased from; however that is decided by the pool.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • discard

      void discard()
      Marks the leased object as discarded, potentially preventing it from being reused in the object pool.