diff --git a/src/main/java/com/threerings/presents/dobj/AttributeChangedEvent.java b/src/main/java/com/threerings/presents/dobj/AttributeChangedEvent.java index ce1c011f0..7e6ffe1ee 100644 --- a/src/main/java/com/threerings/presents/dobj/AttributeChangedEvent.java +++ b/src/main/java/com/threerings/presents/dobj/AttributeChangedEvent.java @@ -44,19 +44,10 @@ public class AttributeChangedEvent extends NamedEvent * @param value the new value of the attribute (in the case of primitive types, the * reflection-defined object-alternative is used). */ - public AttributeChangedEvent (int targetOid, String name, Object value, Object oldValue) + public AttributeChangedEvent (int targetOid, String name, Object value) { super(targetOid, name); _value = value; - _oldValue = oldValue; - } - - /** For unserialization. */ - public AttributeChangedEvent () - { - super(0, null); - // we can't allow our primary ctor to be called during unserialization, or it will wipe out - // the hackery we do with _oldValue } /** @@ -182,6 +173,12 @@ public class AttributeChangedEvent extends NamedEvent StringUtil.toString(buf, _value); } + protected AttributeChangedEvent setOldValue (Object oldValue) + { + _oldValue = oldValue; + return this; + } + protected Object _value; protected transient Object _oldValue = UNSET_OLD_VALUE; } diff --git a/src/main/java/com/threerings/presents/dobj/DObject.java b/src/main/java/com/threerings/presents/dobj/DObject.java index 49b910658..79a9549e1 100644 --- a/src/main/java/com/threerings/presents/dobj/DObject.java +++ b/src/main/java/com/threerings/presents/dobj/DObject.java @@ -871,7 +871,8 @@ public class DObject String name, Object value, Object oldValue, Transport transport) { // dispatch an attribute changed event - postEvent(new AttributeChangedEvent(_oid, name, value, oldValue).setTransport(transport)); + postEvent(new AttributeChangedEvent(_oid, name, value). + setOldValue(oldValue).setTransport(transport)); } /** @@ -889,8 +890,8 @@ public class DObject String name, int index, Object value, Object oldValue, Transport transport) { // dispatch an attribute changed event - postEvent(new ElementUpdatedEvent(_oid, name, value, oldValue, index). - setTransport(transport)); + postEvent(new ElementUpdatedEvent(_oid, name, value, index). + setOldValue(oldValue).setTransport(transport)); } /** @@ -962,7 +963,7 @@ public class DObject } } // dispatch an entry removed event - postEvent(new EntryRemovedEvent(_oid, name, key, oldEntry)); + postEvent(new EntryRemovedEvent(_oid, name, key).setOldEntry(oldEntry)); } /** @@ -989,7 +990,8 @@ public class DObject } } // dispatch an entry updated event - postEvent(new EntryUpdatedEvent(_oid, name, entry, oldEntry).setTransport(transport)); + postEvent(new EntryUpdatedEvent(_oid, name, entry). + setOldEntry(oldEntry).setTransport(transport)); } protected boolean isAuthoritative () diff --git a/src/main/java/com/threerings/presents/dobj/ElementUpdatedEvent.java b/src/main/java/com/threerings/presents/dobj/ElementUpdatedEvent.java index ba91ddb4b..a87e89908 100644 --- a/src/main/java/com/threerings/presents/dobj/ElementUpdatedEvent.java +++ b/src/main/java/com/threerings/presents/dobj/ElementUpdatedEvent.java @@ -43,18 +43,23 @@ public class ElementUpdatedEvent extends NamedEvent * @param name the name of the attribute (data member) for which an element has changed. * @param value the new value of the element (in the case of primitive types, the * reflection-defined object-alternative is used). - * @param ovalue the previous value of the element (in the case of primitive types, the - * reflection-defined object-alternative is used). * @param index the index in the array of the updated element. */ - public ElementUpdatedEvent (int targetOid, String name, Object value, Object ovalue, int index) + public ElementUpdatedEvent (int targetOid, String name, Object value, int index) { super(targetOid, name); _value = value; - _oldValue = ovalue; _index = index; } + /** For unserialization. */ + public ElementUpdatedEvent () + { + super(0, null); + // we can't allow our primary ctor to be called during unserialization, or it will wipe out + // the hackery we do with _oldValue + } + /** * Returns the new value of the element. */ @@ -180,6 +185,12 @@ public class ElementUpdatedEvent extends NamedEvent buf.append(", index=").append(_index); } + protected ElementUpdatedEvent setOldValue (Object oldValue) + { + _oldValue = oldValue; + return this; + } + protected Object _value; protected int _index; protected transient Object _oldValue = UNSET_OLD_VALUE; diff --git a/src/main/java/com/threerings/presents/dobj/EntryRemovedEvent.java b/src/main/java/com/threerings/presents/dobj/EntryRemovedEvent.java index 1cca07698..d1f018c31 100644 --- a/src/main/java/com/threerings/presents/dobj/EntryRemovedEvent.java +++ b/src/main/java/com/threerings/presents/dobj/EntryRemovedEvent.java @@ -42,21 +42,11 @@ public class EntryRemovedEvent extends EntryEvent * @param targetOid the object id of the object from whose set we will remove an entry. * @param name the name of the attribute from which to remove the specified entry. * @param key the entry key that identifies the entry to remove. - * @param oldEntry the previous value of the entry. */ - public EntryRemovedEvent (int targetOid, String name, Comparable key, T oldEntry) + public EntryRemovedEvent (int targetOid, String name, Comparable key) { super(targetOid, name); _key = key; - _oldEntry = oldEntry; - } - - /** For unserialization. */ - public EntryRemovedEvent () - { - super(0, null); - // we can't allow our primary ctor to be called during unserialization, or it will wipe out - // the hackery we do with _oldEntry } @Override @@ -125,6 +115,12 @@ public class EntryRemovedEvent extends EntryEvent buf.append(", key=").append(_key); } + protected EntryRemovedEvent setOldEntry (T oldEntry) + { + _oldEntry = oldEntry; + return this; + } + protected Comparable _key; @SuppressWarnings("unchecked") diff --git a/src/main/java/com/threerings/presents/dobj/EntryUpdatedEvent.java b/src/main/java/com/threerings/presents/dobj/EntryUpdatedEvent.java index 7c2da4493..9f7ac1818 100644 --- a/src/main/java/com/threerings/presents/dobj/EntryUpdatedEvent.java +++ b/src/main/java/com/threerings/presents/dobj/EntryUpdatedEvent.java @@ -43,21 +43,11 @@ public class EntryUpdatedEvent extends EntryEvent * @param targetOid the object id of the object to whose set we will add an entry. * @param name the name of the attribute in which to update the specified entry. * @param entry the entry to update. - * @param oldEntry the previous value of the entry. */ - public EntryUpdatedEvent (int targetOid, String name, T entry, T oldEntry) + public EntryUpdatedEvent (int targetOid, String name, T entry) { super(targetOid, name); _entry = entry; - _oldEntry = oldEntry; - } - - /** For unserialization. */ - public EntryUpdatedEvent () - { - super(0, null); - // we can't allow our primary ctor to be called during unserialization, or it will wipe out - // the hackery we do with _oldEntry } @Override @@ -128,6 +118,12 @@ public class EntryUpdatedEvent extends EntryEvent StringUtil.toString(buf, _entry); } + protected EntryUpdatedEvent setOldEntry (T oldEntry) + { + _oldEntry = oldEntry; + return this; + } + protected T _entry; @SuppressWarnings("unchecked")