@Override public void putIfAbsent(K k, V v, long timeout, Handler<AsyncResult<V>> completionHandler) { checkType(k); checkType(v); delegate.putIfAbsent(k, v, timeout, completionHandler); }
@Override public void putIfAbsent(K k, V v, Handler<AsyncResult<V>> completionHandler) { checkType(k); checkType(v); delegate.putIfAbsent(k, v, completionHandler); }
@Override public void putIfAbsent(K k, V v, long timeout, Handler<AsyncResult<V>> completionHandler) { checkType(k); checkType(v); delegate.putIfAbsent(k, v, timeout, completionHandler); }
@Override public void putIfAbsent(K k, V v, Handler<AsyncResult<V>> completionHandler) { checkType(k); checkType(v); delegate.putIfAbsent(k, v, completionHandler); }
@Test public void testPutIfAbsentInvalidValue() { getVertx().sharedData().<String, SomeObject>getAsyncMap("foo", onSuccess(map -> { assertIllegalArgumentException(() -> map.putIfAbsent("foo", new SomeObject(), ar2 -> {})); testComplete(); })); await(); }
@Test public void testPutIfAbsentInvalidKey() { getVertx().sharedData().<SomeObject, String>getAsyncMap("foo", onSuccess(map -> { assertIllegalArgumentException(() -> map.putIfAbsent(new SomeObject(), "foo", ar2 -> {})); testComplete(); })); await(); }
private <K, V> void testMapPutIfAbsentGet(K k, V v) { getVertx().sharedData().<K, V>getAsyncMap("foo", onSuccess(map -> { map.putIfAbsent(k, v, onSuccess(res -> { assertNull(res); getVertx().sharedData().<K, V>getAsyncMap("foo", onSuccess(map2 -> { map2.get(k, onSuccess(res2 -> { assertEquals(v, res2); map.putIfAbsent(k, v, onSuccess(res3 -> { assertEquals(v, res3); testComplete(); })); })); })); })); })); await(); }
@Test public void testMapPutIfAbsentTtl() { getVertx().sharedData().<String, String>getAsyncMap("foo", onSuccess(map -> { map.putIfAbsent("pipo", "molo", 10, onSuccess(vd -> { assertNull(vd); vertx.setTimer(15, l -> { getVertx().sharedData().<String, String>getAsyncMap("foo", onSuccess(map2 -> { map2.get("pipo", onSuccess(res -> { assertNull(res); testComplete(); })); })); }); })); })); await(); }
@Test public void testPutIfAbsentInvalidValue() { getVertx().sharedData().<String, SomeObject>getAsyncMap("foo", onSuccess(map -> { assertIllegalArgumentException(() -> map.putIfAbsent("foo", new SomeObject(), ar2 -> {})); testComplete(); })); await(); }
@Test public void testPutIfAbsentInvalidKey() { getVertx().sharedData().<SomeObject, String>getAsyncMap("foo", onSuccess(map -> { assertIllegalArgumentException(() -> map.putIfAbsent(new SomeObject(), "foo", ar2 -> {})); testComplete(); })); await(); }
private <K, V> void testMapPutIfAbsentGet(K k, V v) { getVertx().sharedData().<K, V>getAsyncMap("foo", onSuccess(map -> { map.putIfAbsent(k, v, onSuccess(res -> { assertNull(res); getVertx().sharedData().<K, V>getAsyncMap("foo", onSuccess(map2 -> { map2.get(k, onSuccess(res2 -> { assertEquals(v, res2); map.putIfAbsent(k, v, onSuccess(res3 -> { assertEquals(v, res3); testComplete(); })); })); })); })); })); await(); }
public static void putIfAbsent(io.vertx.core.shareddata.AsyncMap<Object, Object> j_receiver, java.lang.Object k, java.lang.Object v, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Object>> completionHandler) { j_receiver.putIfAbsent(io.vertx.core.impl.ConversionHelper.toObject(k), io.vertx.core.impl.ConversionHelper.toObject(v), completionHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Object>>() { public void handle(io.vertx.core.AsyncResult<java.lang.Object> ar) { completionHandler.handle(ar.map(event -> io.vertx.core.impl.ConversionHelper.fromObject(event))); } } : null); } public static void putIfAbsent(io.vertx.core.shareddata.AsyncMap<Object, Object> j_receiver, java.lang.Object k, java.lang.Object v, long ttl, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Object>> completionHandler) {
public static void putIfAbsent(io.vertx.core.shareddata.AsyncMap<Object, Object> j_receiver, java.lang.Object k, java.lang.Object v, long ttl, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Object>> completionHandler) { j_receiver.putIfAbsent(io.vertx.core.impl.ConversionHelper.toObject(k), io.vertx.core.impl.ConversionHelper.toObject(v), ttl, completionHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Object>>() { public void handle(io.vertx.core.AsyncResult<java.lang.Object> ar) { completionHandler.handle(ar.map(event -> io.vertx.core.impl.ConversionHelper.fromObject(event))); } } : null); } public static void remove(io.vertx.core.shareddata.AsyncMap<Object, Object> j_receiver, java.lang.Object k, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Object>> resultHandler) {
/** * Put the entry only if there is no entry with the key already present. If key already present then the existing * value will be returned to the handler, otherwise null. * @param k the key * @param v the value * @param completionHandler the handler */ public void putIfAbsent(K k, V v, Handler<AsyncResult<V>> completionHandler) { delegate.putIfAbsent(__typeArg_0.<K>unwrap(k), __typeArg_1.<V>unwrap(v), new Handler<AsyncResult<V>>() { public void handle(AsyncResult<V> ar) { if (ar.succeeded()) { completionHandler.handle(io.vertx.core.Future.succeededFuture((V)__typeArg_1.wrap(ar.result()))); } else { completionHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
/** * Link {@link io.vertx.rxjava.core.shareddata.AsyncMap#putIfAbsent} but specifying a time to live for the entry. Entry will expire and get evicted * after the ttl. * @param k the key * @param v the value * @param ttl The time to live (in ms) for the entry * @param completionHandler the handler */ public void putIfAbsent(K k, V v, long ttl, Handler<AsyncResult<V>> completionHandler) { delegate.putIfAbsent(__typeArg_0.<K>unwrap(k), __typeArg_1.<V>unwrap(v), ttl, new Handler<AsyncResult<V>>() { public void handle(AsyncResult<V> ar) { if (ar.succeeded()) { completionHandler.handle(io.vertx.core.Future.succeededFuture((V)__typeArg_1.wrap(ar.result()))); } else { completionHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
/** * Put the entry only if there is no entry with the key already present. If key already present then the existing * value will be returned to the handler, otherwise null. * @param k the key * @param v the value * @param completionHandler the handler */ public void putIfAbsent(K k, V v, Handler<AsyncResult<V>> completionHandler) { delegate.putIfAbsent(__typeArg_0.<K>unwrap(k), __typeArg_1.<V>unwrap(v), new Handler<AsyncResult<V>>() { public void handle(AsyncResult<V> ar) { if (ar.succeeded()) { completionHandler.handle(io.vertx.core.Future.succeededFuture((V)__typeArg_1.wrap(ar.result()))); } else { completionHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
/** * Link {@link io.vertx.rxjava.core.shareddata.AsyncMap#putIfAbsent} but specifying a time to live for the entry. Entry will expire and get evicted * after the ttl. * @param k the key * @param v the value * @param ttl The time to live (in ms) for the entry * @param completionHandler the handler */ public void putIfAbsent(K k, V v, long ttl, Handler<AsyncResult<V>> completionHandler) { delegate.putIfAbsent(__typeArg_0.<K>unwrap(k), __typeArg_1.<V>unwrap(v), ttl, new Handler<AsyncResult<V>>() { public void handle(AsyncResult<V> ar) { if (ar.succeeded()) { completionHandler.handle(io.vertx.core.Future.succeededFuture((V)__typeArg_1.wrap(ar.result()))); } else { completionHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
@Test public void testMapPutIfAbsentTtl() { getVertx().sharedData().<String, String>getAsyncMap("foo", onSuccess(map -> { map.putIfAbsent("pipo", "molo", 10, onSuccess(vd -> { assertNull(vd); vertx.setTimer(15, l -> { getVertx().sharedData().<String, String>getAsyncMap("foo", onSuccess(map2 -> { map2.get("pipo", onSuccess(res -> { assertNull(res); testComplete(); })); })); }); })); })); await(); }
@Override @Test public void testMapPutIfAbsentTtl() { getVertx().sharedData().<String, String>getAsyncMap("foo", onSuccess(map -> { map.putIfAbsent("pipo", "molo", 150, onSuccess(vd -> { assertNull(vd); vertx.setTimer(300, l -> { getVertx().sharedData().<String, String>getAsyncMap("foo", onSuccess(map2 -> { map2.get("pipo", onSuccess(res -> { assertNull(res); testComplete(); })); })); }); })); })); await(); }
@Override @Test public void testMapPutIfAbsentTtl() { getVertx().sharedData().<String, String>getAsyncMap("foo", onSuccess(map -> { map.putIfAbsent("pipo", "molo", 150, onSuccess(vd -> { assertNull(vd); vertx.setTimer(300, l -> { getVertx().sharedData().<String, String>getAsyncMap("foo", onSuccess(map2 -> { map2.get("pipo", onSuccess(res -> { assertNull(res); testComplete(); })); })); }); })); })); await(); }