All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.tp.ke.refine.KeTool Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
package io.vertx.tp.ke.refine;

import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
import io.vertx.up.unity.Ux;
import io.vertx.up.uca.yaml.Node;
import io.vertx.up.uca.yaml.ZeroUniform;
import io.vertx.up.util.Ut;

import java.util.function.Supplier;

class KeTool {

    private static final Node VISITOR = Ut.singleton(ZeroUniform.class);

    static String getCatalog() {
        final JsonObject config = VISITOR.read();
        return Ut.visitString(config, "jooq", "provider", "catalog");
    }

    static  Future poolAsync(final String name,
                                   final String key,
                                   final Supplier> value) {
        return Ux.Pool.on(name).get(key).compose(item -> {
            if (null == item) {
                return value.get().compose(updated ->
                        Ux.Pool.on(name).put(key, updated)
                                .compose(kv -> Ux.toFuture(kv.getValue())));
            } else {
                return Ux.toFuture(item);
            }
        });
    }

    static void banner(final String module) {
        System.out.println("-------------------------------------------------------------");
        System.out.println("|                                                           |");
        System.out.println("|     Zero Extension:  " + module);
        System.out.println("|                                                           |");
        System.out.println("-------------------------------------------------------------");
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy