MCPcopy Create free account
hub / github.com/apache/groovy / putAll

Method putAll

src/main/java/groovy/util/ObservableMap.java:277–319  ·  view source on GitHub ↗

{@inheritDoc}

(Map map)

Source from the content-addressed store, hash-verified

275
276 /** {@inheritDoc} */
277 @Override
278 public void putAll(Map map) {
279 int oldSize = size();
280 if (map != null) {
281 List<PropertyEvent> events = new ArrayList<PropertyEvent>();
282 for (Object o : map.entrySet()) {
283 Entry entry = (Entry) o;
284
285 String key = String.valueOf(entry.getKey());
286 Object newValue = entry.getValue();
287 Object oldValue = null;
288
289 boolean newKey = !delegate.containsKey(key);
290 if (test != null) {
291 oldValue = delegate.put(key, newValue);
292 Object result = null;
293 if (test.getMaximumNumberOfParameters() == 2) {
294 result = test.call(key, newValue);
295 } else {
296 result = test.call(newValue);
297 }
298 if (result instanceof Boolean && (Boolean) result) {
299 if (newKey) {
300 events.add(new PropertyAddedEvent(this, key, newValue));
301 } else if (oldValue != newValue) {
302 events.add(new PropertyUpdatedEvent(this, key, oldValue, newValue));
303 }
304 }
305 } else {
306 oldValue = delegate.put(key, newValue);
307 if (newKey) {
308 events.add(new PropertyAddedEvent(this, key, newValue));
309 } else if (oldValue != newValue) {
310 events.add(new PropertyUpdatedEvent(this, key, oldValue, newValue));
311 }
312 }
313 }
314 if (!events.isEmpty()) {
315 fireMultiPropertyEvent(events);
316 fireSizeChangedEvent(oldSize, size());
317 }
318 }
319 }
320
321 /** {@inheritDoc} */
322 @Override

Callers 2

clearMethod · 0.45
PropertyClearedEventMethod · 0.45

Calls 13

sizeMethod · 0.95
getKeyMethod · 0.95
getValueMethod · 0.95
fireSizeChangedEventMethod · 0.95
containsKeyMethod · 0.65
putMethod · 0.65
callMethod · 0.65
addMethod · 0.65
entrySetMethod · 0.45
valueOfMethod · 0.45

Tested by

no test coverage detected