Interface Resource<T extends Resource<T>>

Type Parameters:
T - The type that is held in this resource.
All Superinterfaces:
AutoCloseable
All Known Subinterfaces:
ProtonBuffer, ProtonCompositeBuffer
All Known Implementing Classes:
Netty4ToProtonBufferAdapter, Netty5ToProtonBufferAdapter, ProtonByteArrayBuffer, ProtonCompositeBufferImpl, SharedResource

public interface Resource<T extends Resource<T>> extends AutoCloseable
Base resource type that provides API for managing ownership and cleaning up resources that require explicit life-cycle management.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close the resource and free any managed resources it might own.
    boolean
    A Resource is closed either following a call to the close() method or by the resource being transfered by way of the transfer() method.
    Transfers ownership of this resource from one owner to another.
  • Method Details

    • close

      void close()
      Close the resource and free any managed resources it might own. Calling close on a closed resource should not result in any exceptions being thrown.
      Specified by:
      close in interface AutoCloseable
    • transfer

      T transfer()
      Transfers ownership of this resource from one owner to another.

      Upon transferring a resource the original referenced value is closed and its contents are migrated to a new view that has the same state as the original view but it now the property of the caller and who's life-cycle now must be managed by the caller.

      Returns:
      the a new transfered view of the given resource now owned by the caller.
    • isClosed

      boolean isClosed()
      A Resource is closed either following a call to the close() method or by the resource being transfered by way of the transfer() method.
      Returns:
      true if this resource is closed, either by being transfered or by direct close().