@Override public void replaceIfPresent(K k, V oldValue, V newValue, Handler<AsyncResult<Boolean>> resultHandler) { checkType(k); checkType(oldValue); checkType(newValue); delegate.replaceIfPresent(k, oldValue, newValue, resultHandler); }
@Override public void replaceIfPresent(K k, V oldValue, V newValue, Handler<AsyncResult<Boolean>> resultHandler) { checkType(k); checkType(oldValue); checkType(newValue); delegate.replaceIfPresent(k, oldValue, newValue, resultHandler); }
private <K, V> void testMapReplaceIfPresent(K k, V v, V other) { getVertx().sharedData().<K, V>getAsyncMap("foo", onSuccess(map -> { map.put(k, v, onSuccess(res -> { assertNull(res); getVertx().sharedData().<K, V>getAsyncMap("foo", onSuccess(map2 -> { map2.replaceIfPresent(k, v, other, onSuccess(res2 -> { map2.replaceIfPresent(k, v, other, onSuccess(res3 -> { assertFalse(res3); map2.get(k, onSuccess(res4 -> { assertEquals(other, res4); testComplete(); })); })); })); })); })); })); await(); }
private <K, V> void testMapReplaceIfPresent(K k, V v, V other) { getVertx().sharedData().<K, V>getAsyncMap("foo", onSuccess(map -> { map.put(k, v, onSuccess(res -> { assertNull(res); getVertx().sharedData().<K, V>getAsyncMap("foo", onSuccess(map2 -> { map2.replaceIfPresent(k, v, other, onSuccess(res2 -> { map2.replaceIfPresent(k, v, other, onSuccess(res3 -> { assertFalse(res3); map2.get(k, onSuccess(res4 -> { assertEquals(other, res4); testComplete(); })); })); })); })); })); })); await(); }
/** * Replace the entry only if it is currently mapped to a specific value * @param k the key * @param oldValue the existing value * @param newValue the new value * @param resultHandler the result handler */ public void replaceIfPresent(K k, V oldValue, V newValue, Handler<AsyncResult<Boolean>> resultHandler) { delegate.replaceIfPresent(__typeArg_0.<K>unwrap(k), __typeArg_1.<V>unwrap(oldValue), __typeArg_1.<V>unwrap(newValue), resultHandler); }
public static void replaceIfPresent(io.vertx.core.shareddata.AsyncMap<Object, Object> j_receiver, java.lang.Object k, java.lang.Object oldValue, java.lang.Object newValue, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>> resultHandler) { j_receiver.replaceIfPresent(io.vertx.core.impl.ConversionHelper.toObject(k), io.vertx.core.impl.ConversionHelper.toObject(oldValue), io.vertx.core.impl.ConversionHelper.toObject(newValue), resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>() { public void handle(io.vertx.core.AsyncResult<java.lang.Boolean> ar) { resultHandler.handle(ar.map(event -> event)); } } : null); } }
/** * Replace the entry only if it is currently mapped to a specific value * @param k the key * @param oldValue the existing value * @param newValue the new value * @param resultHandler the result handler */ public void replaceIfPresent(K k, V oldValue, V newValue, Handler<AsyncResult<Boolean>> resultHandler) { delegate.replaceIfPresent(__typeArg_0.<K>unwrap(k), __typeArg_1.<V>unwrap(oldValue), __typeArg_1.<V>unwrap(newValue), resultHandler); }
private void addOrReplace2(boolean allowReplace, String k, String k2, String value, String oldVal, String newVal, Handler<ExtendedAsyncResult<Void>> fut) { if (oldVal == null) { // new entry list.putIfAbsent(k, newVal, resPut -> { if (resPut.succeeded()) { if (resPut.result() == null) { fut.handle(new Success<>()); } else { // Someone messed with it, try again vertx.setTimer(DELAY, res -> addOrReplace(allowReplace, k, k2, value, fut)); } } else { fut.handle(new Failure<>(INTERNAL, resPut.cause())); } }); } else { // existing entry, put and retry if someone else messed with it list.replaceIfPresent(k, oldVal, newVal, resRepl -> { if (resRepl.succeeded()) { if (resRepl.result()) { fut.handle(new Success<>()); } else { vertx.setTimer(DELAY, res -> addOrReplace(allowReplace, k, k2, value, fut)); } } else { fut.handle(new Failure<>(INTERNAL, resRepl.cause())); } }); } }
private void remove2(String k, String k2, StringMap smap, String val, Handler<ExtendedAsyncResult<Boolean>> fut) { if (smap.strings.isEmpty()) { list.removeIfPresent(k, val, resDel -> { if (resDel.succeeded()) { if (resDel.result()) { fut.handle(new Success<>(true)); } else { vertx.setTimer(DELAY, res -> remove(k, k2, fut)); } } else { fut.handle(new Failure<>(INTERNAL, resDel.cause())); } }); } else { // list was not empty, remove value String newVal = Json.encodePrettily(smap); list.replaceIfPresent(k, val, newVal, resPut -> { if (resPut.succeeded()) { if (resPut.result()) { fut.handle(new Success<>(false)); } else { vertx.setTimer(DELAY, res -> remove(k, k2, fut)); } } else { fut.handle(new Failure<>(INTERNAL, resPut.cause())); } }); } }