private CDORevision applyDelta(CDORevisionDelta revisionDelta) {
   CDOID id = revisionDelta.getID();
   CDORevision changedObject = delegate.getRevision(id).copy();
   revisionDelta.apply(changedObject);
   cachedRevisions.put(id, changedObject);
   return changedObject;
 }
  public synchronized CDORevision getRevision(CDOID id) {
    if (cachedRevisions == null) {
      cachedRevisions = cacheRevisions();
    }

    CDOIDAndVersion key = cachedRevisions.get(id);
    if (key == DETACHED) {
      return null;
    }

    if (key instanceof CDORevision) // New object (eager)
    {
      return (CDORevision) key;
    }

    if (key instanceof CDORevisionDelta) // Changed object (eager)
    {
      CDORevisionDelta revisionDelta = (CDORevisionDelta) key;
      return applyDelta(revisionDelta);
    }

    if (key instanceof CDORevisionKey) // Changed object (lazy)
    {
      CDORevisionDelta revisionDelta = revisionDeltaCallback.getRevisionDelta(id);
      return applyDelta(revisionDelta);
    }

    if (key != null) // New object (lazy)
    {
      CDORevision revision = revisionCallback.getRevision(id);
      cachedRevisions.put(id, revision);
      return revision;
    }

    return delegate.getRevision(id);
  }