private ValueHolder<V> updateCommandForKey(K key, BiFunction<? super K, ? super V, ? extends V> mappingFunction, Supplier<Boolean> replaceEqual, XATransactionContext<K, V> currentContext) { V newValue = mappingFunction.apply(key, currentContext.newValueOf(key)); XAValueHolder<V> xaValueHolder = null; V oldValue = currentContext.oldValueOf(key); if (newValue == null) { if (!(oldValue == null && !replaceEqual.get())) { currentContext.addCommand(key, new StoreRemoveCommand<>(oldValue)); } else { currentContext.removeCommand(key); } } else { checkValue(newValue); xaValueHolder = new XAValueHolder<>(newValue, timeSource.getTimeMillis()); if (!(Objects.equals(oldValue, newValue) && !replaceEqual.get())) { currentContext.addCommand(key, new StorePutCommand<>(oldValue, xaValueHolder)); } } return xaValueHolder; }
currentContext.addCommand(key, new StoreRemoveCommand<>(oldValue)); } else { currentContext.removeCommand(key);
private ValueHolder<V> updateCommandForKey(K key, BiFunction<? super K, ? super V, ? extends V> mappingFunction, Supplier<Boolean> replaceEqual, XATransactionContext<K, V> currentContext) { V newValue = mappingFunction.apply(key, currentContext.newValueOf(key)); XAValueHolder<V> xaValueHolder = null; V oldValue = currentContext.oldValueOf(key); if (newValue == null) { if (!(oldValue == null && !replaceEqual.get())) { currentContext.addCommand(key, new StoreRemoveCommand<>(oldValue)); } else { currentContext.removeCommand(key); } } else { checkValue(newValue); xaValueHolder = new XAValueHolder<>(newValue, timeSource.getTimeMillis()); if (!(Objects.equals(oldValue, newValue) && !replaceEqual.get())) { currentContext.addCommand(key, new StorePutCommand<>(oldValue, xaValueHolder)); } } return xaValueHolder; }