@@ -1876,7 +1876,7 @@ public JSONObject update(String key, Object newValue) throws JSONException {
1876
1876
* If updateListener not initialized.
1877
1877
*/
1878
1878
public JSONObject update (JSONObject jo ) throws JSONException {
1879
- return this .updateOrRemove (jo , false );
1879
+ return this .updateOrRemove (jo , false , true );
1880
1880
}
1881
1881
1882
1882
/**
@@ -1896,10 +1896,18 @@ public JSONObject update(JSONObject jo) throws JSONException {
1896
1896
* If updateListener not initialized.
1897
1897
*/
1898
1898
public JSONObject updateOrRemove (JSONObject jo ) throws JSONException {
1899
- return this .updateOrRemove (jo , true );
1899
+ return this .updateOrRemove (jo , true , true );
1900
1900
}
1901
1901
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 {
1903
1911
final JSONObject oldThis = new JSONObject (this .toString ());
1904
1912
1905
1913
final HashMap <String , Object > oldValues = new HashMap <String , Object >();
@@ -1930,24 +1938,26 @@ private JSONObject updateOrRemove(JSONObject jo, boolean remove) throws JSONExce
1930
1938
}
1931
1939
}
1932
1940
1933
- this .propertyChangeSupport .firePropertyChange (JSONObject .propertyChangeGlobalKeyword , oldThis , this );
1941
+ if (triggerEvent ) {
1942
+ this .propertyChangeSupport .firePropertyChange (JSONObject .propertyChangeGlobalKeyword , oldThis , this );
1934
1943
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
+ }
1943
1952
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
+ }
1948
1958
}
1949
- }
1950
- });
1959
+ });
1960
+ }
1951
1961
1952
1962
return this ;
1953
1963
}
0 commit comments