@Override public void noteObtainedReference() { assert !this.isDisposed() : String.format("%s should not be resurrected.", this); this.numReferences++; logger.trace("{} has {} (+1) references now.", this, this.getNumReferences()); }
@Override public boolean disposeIfUnreferenced() { if (this.getNumReferences() == 0) { assert !this.isDisposed() : String.format("%s has already been disposed.", this); logger.debug("Discarding {} for being unreferenced.", this); this.disposeUnreferenced(); this.isDisposed = true; return true; } return false; }