Interface ReferenceCountable

    • Method Detail

      • getNumReferences

        int getNumReferences()
        Tells the number of references on this instance.
        Returns:
        the number of references
      • noteObtainedReference

        void noteObtainedReference()
        Declare that there is a new reference obtained on this instance.
      • noteDiscardedReference

        void noteDiscardedReference​(boolean isDisposeIfUnreferenced)
        Declare that a reference on this instance has been discarded. Optionally, dispose this instance if there are no remaining references.
        Parameters:
        isDisposeIfUnreferenced - whether to dispose this instance if there are no more references
      • disposeIfUnreferenced

        boolean disposeIfUnreferenced()
        Dispose this instance if there are no more references to it.
        Returns:
        whether this instance is not referenced any more
      • isDisposed

        default boolean isDisposed()
        Optional operation. Tell whether this instance has been disposed.
        Returns:
        whether this instance has been disposed