Provide access to the values that existed previous to the application of

events that change values.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1837 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-10-27 01:33:43 +00:00
parent bb489caf39
commit 76ba2840c4
3 changed files with 40 additions and 3 deletions
@@ -1,5 +1,5 @@
//
// $Id: EntryUpdatedEvent.java,v 1.7 2002/07/23 05:52:48 mdb Exp $
// $Id: EntryUpdatedEvent.java,v 1.8 2002/10/27 01:33:43 mdb Exp $
package com.threerings.presents.dobj;
@@ -63,6 +63,14 @@ public class EntryUpdatedEvent extends DEvent
return _entry;
}
/**
* Returns the entry that was in the set prior to being updated.
*/
public DSet.Entry getOldEntry ()
{
return _oldEntry;
}
/**
* Applies this event to the object.
*/
@@ -71,6 +79,9 @@ public class EntryUpdatedEvent extends DEvent
{
DSet set = (DSet)target.getAttribute(_name);
// fetch the previous value for interested callers
_oldEntry = set.get(_entry.getKey());
// update the entry
if (!set.update(_entry)) {
// complain if we didn't update anything
@@ -124,4 +135,5 @@ public class EntryUpdatedEvent extends DEvent
protected String _name;
protected DSet.Entry _entry;
protected transient DSet.Entry _oldEntry;
}