/** * @see java.util.Hashtable#clear() */ public synchronized void clear() { if (hasTrackedPropertyChangeListener()) { Iterator objects = this.keySet().iterator(); while (objects.hasNext()) { Object o = objects.next(); objects.remove(); this.raiseRemoveChangeEvent(o, this.get(o)); } } else { this.getDelegate().clear(); } }
/** * @see java.util.Hashtable#clear() */ @Override public synchronized void clear() { if (hasTrackedPropertyChangeListener()) { Iterator<K> objects = this.keySet().iterator(); while (objects.hasNext()) { K o = objects.next(); objects.remove(); // should remove this to not fire same event twice this.raiseRemoveChangeEvent(o, this.get(o)); } } else { this.getDelegate().clear(); } }
@Override public synchronized V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction) { // Must trigger add events if tracked or uow. if (hasTrackedPropertyChangeListener()) { V oldValue = get(key); if (oldValue == null) { V newValue = mappingFunction.apply(key); if (newValue != null) { put(key, newValue); } return newValue; } return oldValue; } return getDelegate().computeIfAbsent(key, mappingFunction); }
@Override public synchronized V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction) { // Must trigger add events if tracked or uow. if (hasTrackedPropertyChangeListener()) { if (get(key) != null) { V oldValue = get(key); V newValue = remappingFunction.apply(key, oldValue); if (newValue != null) { put(key, newValue); return newValue; } remove(key); } return null; } return getDelegate().computeIfPresent(key, remappingFunction); }
@Override public synchronized V merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction) { // Must trigger add events if tracked or uow. if (hasTrackedPropertyChangeListener()) { V oldValue = get(key); V newValue = (oldValue == null) ? value : remappingFunction.apply(oldValue, value); if (newValue == null) { remove(key); } else { put(key, newValue); } return newValue; } return getDelegate().merge(key, value, remappingFunction); }
@Override public synchronized V compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction) { // Must trigger add events if tracked or uow. if (hasTrackedPropertyChangeListener()) { V oldValue = get(key); V newValue = remappingFunction.apply(key, oldValue); if (oldValue != null ) { if (newValue != null) { put(key, newValue); return newValue; } remove(key); } else { if (newValue != null) { put(key, newValue); return newValue; } } return null; } return getDelegate().compute(key, remappingFunction); }