public Object putIfAbsent(Object key, Object value) {
checkTransactionState();
TxnValueWrapper wrapper = txMap.get(key);
boolean haveTxnPast = wrapper != null;
MapService service = getService();
final MapServiceContext mapServiceContext = service.getMapServiceContext();
if (haveTxnPast) {
if (wrapper.type != TxnValueWrapper.Type.REMOVED) {
return wrapper.value;
}
putInternal(mapServiceContext.toData(key, partitionStrategy), mapServiceContext.toData(value));
txMap.put(key, new TxnValueWrapper(value, TxnValueWrapper.Type.NEW));
return null;
} else {
Data oldValue
= putIfAbsentInternal(mapServiceContext.toData(key, partitionStrategy),
mapServiceContext.toData(value));
if (oldValue == null) {
txMap.put(key, new TxnValueWrapper(value, TxnValueWrapper.Type.NEW));
}
return mapServiceContext.toObject(oldValue);
}
}