class LockUtil {

    public static Future<Boolean> acquireLock(Lock lockImpl, String lock, String token, long lockExpiryMs, Logger log){
        Future<Boolean> future = Future.future();

        if(lockImpl == null){
            log.info("No lock implementation defined, going to pretend like we got the lock");
            future.complete(Boolean.TRUE);
            return future;
        }

        log.debug("Trying to acquire lock '"+lock+"' with token '"+token+"' and expiry " + lockExpiryMs + "ms");
        lockImpl.acquireLock(lock, token, lockExpiryMs).setHandler(lockEvent -> {
            if(lockEvent.succeeded()){
                if(lockEvent.result()){
                    log.debug("Acquired lock '"+lock+"' with token '"+token+"'");
                    future.complete(Boolean.TRUE);
                } else {
                    future.complete(Boolean.FALSE);
                }
            } else {
                future.fail(lockEvent.cause());
            }
        });

        return future;
    }

    private  LockUtil();

}