protected void propertyChanged ( String propertyName , Object orgValue , Object newValue ) { if ( propertyChanges . containsKey ( propertyName ) ) { // update an existing change to save the original value Object oldOrgValue = propertyChanges . get ( propertyName ) . getOrgValue ( ) ; if ( ( oldOrgValue == null && newValue == null ) // change back to null || ( oldOrgValue != null && oldOrgValue . equals ( newValue ) ) ) { // remove this change propertyChanges . remove ( propertyName ) ; } else { propertyChanges . get ( propertyName ) . setNewValue ( newValue ) ; } } else { // save this change if ( ( orgValue == null && newValue != null ) // null to value || ( orgValue != null && newValue == null ) // value to null || ( orgValue != null && ! orgValue . equals ( newValue ) ) ) // value change propertyChanges . put ( propertyName , new PropertyChange ( propertyName , orgValue , newValue ) ) ; } }
Tracks a property change . Therefore the original and new value are stored in a map . It tracks multiple changes and if a property finally is changed back to the original value then the change is removed .