Class DatabaseRef<T extends NdNode>

java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.nd.DatabaseRef<T>
All Implemented Interfaces:
Supplier<T>

public class DatabaseRef<T extends NdNode> extends Object implements Supplier<T>
Holds a reference to a database entity that may be retained across read locks. In normal circumstances, it is unsafe to retain a database address after a read lock is released since the object pointed to at that address may have been deleted in the meantime. This class addresses this problem by remembering both the address itself and enough information to determine whether that address is invalid and search for an equivalent object if the original is lost.
  • Constructor Details

    • DatabaseRef

      public DatabaseRef(Nd nd, Supplier<T> searchFunction)
      Constructs a new DatabaseRef that will search for its target using the given search function.
    • DatabaseRef

      public DatabaseRef(Nd nd, Supplier<T> searchFunction, T initialResult)
      Constructs a new DatabaseRef that will search for its target using the given search function.
  • Method Details

    • get

      public T get()
      Returns the referenced object or null if the object is no longer present in the database.
      Specified by:
      get in interface Supplier<T extends NdNode>
    • getNd

      public Nd getNd()
    • lock

      public IReader lock()
      Acquires a read lock. Callers must invoke close() on the result when done.