@@ -1876,7 +1876,7 @@ public JSONObject update(String key, Object newValue) throws JSONException {
18761876 * If updateListener not initialized.
18771877 */
18781878 public JSONObject update (JSONObject jo ) throws JSONException {
1879- return this .updateOrRemove (jo , false );
1879+ return this .updateOrRemove (jo , false , true );
18801880 }
18811881
18821882 /**
@@ -1896,10 +1896,18 @@ public JSONObject update(JSONObject jo) throws JSONException {
18961896 * If updateListener not initialized.
18971897 */
18981898 public JSONObject updateOrRemove (JSONObject jo ) throws JSONException {
1899- return this .updateOrRemove (jo , true );
1899+ return this .updateOrRemove (jo , true , true );
19001900 }
19011901
1902- private JSONObject updateOrRemove (JSONObject jo , boolean remove ) throws JSONException {
1902+ public JSONObject mix (JSONObject jo ) throws JSONException {
1903+ return this .updateOrRemove (jo , false , false );
1904+ }
1905+
1906+ public JSONObject mixOrRemove (JSONObject jo ) throws JSONException {
1907+ return this .updateOrRemove (jo , true , false );
1908+ }
1909+
1910+ private JSONObject updateOrRemove (JSONObject jo , boolean remove , boolean triggerEvent ) throws JSONException {
19031911 final JSONObject oldThis = new JSONObject (this .toString ());
19041912
19051913 final HashMap <String , Object > oldValues = new HashMap <String , Object >();
@@ -1930,24 +1938,26 @@ private JSONObject updateOrRemove(JSONObject jo, boolean remove) throws JSONExce
19301938 }
19311939 }
19321940
1933- this .propertyChangeSupport .firePropertyChange (JSONObject .propertyChangeGlobalKeyword , oldThis , this );
1941+ if (triggerEvent ) {
1942+ this .propertyChangeSupport .firePropertyChange (JSONObject .propertyChangeGlobalKeyword , oldThis , this );
19341943
1935- oldValues .forEach ((key , oldValue ) -> {
1936- if (this .propertyChangeSupport .hasListeners (key )) {
1937- final Object newValue ;
1938- if (remove && delValues .contains (key )) {
1939- newValue = null ;
1940- } else {
1941- newValue = newValues .get (key );
1942- }
1944+ oldValues .forEach ((key , oldValue ) -> {
1945+ if (this .propertyChangeSupport .hasListeners (key )) {
1946+ final Object newValue ;
1947+ if (remove && delValues .contains (key )) {
1948+ newValue = null ;
1949+ } else {
1950+ newValue = newValues .get (key );
1951+ }
19431952
1944- if (oldValue == null && newValue == null ) {
1945- this .propertyChangeSupport .firePropertyChange (key , JSONObject .NULL , newValue );
1946- } else {
1947- this .propertyChangeSupport .firePropertyChange (key , oldValue , newValue );
1953+ if (oldValue == null && newValue == null ) {
1954+ this .propertyChangeSupport .firePropertyChange (key , JSONObject .NULL , newValue );
1955+ } else {
1956+ this .propertyChangeSupport .firePropertyChange (key , oldValue , newValue );
1957+ }
19481958 }
1949- }
1950- });
1959+ });
1960+ }
19511961
19521962 return this ;
19531963 }
0 commit comments