io.vertx.up.unity.readme.txt Maven / Gradle / Ivy
Old Api code of Ux segments:
/*
// -> IfElse true -> Future, false -> Future
public static Future thenOtherwise(final Future condition, final Supplier> trueFuture, final Function trueFun, final Supplier> falseFuture, final Function falseFun) {
return Fluctuate.thenOtherwise(condition, trueFuture, trueFun, falseFuture, falseFun);
} */
/*
// -> IfOr true -> Future, false -> Future
public static Future thenError(final Future condition, final Supplier> trueFuture, final Function trueFun, final Class extends WebException> clazz, final Object... args) {
return Fluctuate.thenOtherwise(condition, trueFuture, trueFun, clazz, args);
}
// -> IfOr true -> Future, false -> Future
public static Future thenError(final Future condition, final Supplier> trueFuture, final Class extends WebException> clazz, final Object... args) {
return Fluctuate.thenOtherwise(condition, trueFuture, item -> item, clazz, args);
}*/
/*
// -> If only true -> Future
public static Future thenTrue(final Future condition, final Supplier> trueFuture, final Function trueFun) {
return Fluctuate.thenOtherwise(condition, trueFuture, trueFun, null);
} */
// -> Merge multi Future<> to single one, one for all module.
public static Future thenComposite(final Future source, final BiFunction, T> mergeFun, final Function>... functions) {
return Fluctuate.thenComposite(source, mergeFun, functions);
}
public static Future thenComposite(final Future source, final BiFunction, T> mergeFun, final Supplier>... suppliers) {
return Fluctuate.thenComposite(source, mergeFun, suppliers);
}
public static Future thenParallelJson(final Future source, final Function> generateFun, final BiConsumer... operatorFun) {
return Fluctuate.thenParallelJson(source, generateFun, operatorFun);
}
public static Future> thenParallel(final Future> source, final Function> generateFun, final BiFunction mergeFun) {
return Fluctuate.thenParallel(source, generateFun, mergeFun);
}
public static Future thenParallelArray(final Future... sources) {
return Fluctuate.thenParallelArray(sources);
}
public static Future thenParallelJson(final Future... sources) {
return Fluctuate.thenParallelJson(sources);
}
/**
* Scatter generate
* Source ->
* source1 -> Future>
* source2 -> Future>
* Fore each element mergage 1, List<2> -> 3
*
* @param source JsonArray
* @param generateFun JsonObject -> Future
* @param mergeFun Each element: JsonObject + JsonArray -> JsonObject
* @return JsonArray
*/
public static Future thenScatterJson(final Future source, final Function> generateFun, final BiFunction mergeFun) {
return Fluctuate.thenScatterJson(source, generateFun, mergeFun);
}
public static Future> thenSet(final List data, final Function> fun) {
return Fluctuate.thenSet(data, fun);
}
/**
* Merge multi Future<> to single one, one for all module.
* source ->
* supplier1
* supplier2
* supplier3
* .....
* All suppliers will be executed after source, then return the final Future.
*
* @param mergeFun How to merge source result and all supplier's results into final result:
* @param source Single Future --> F
* @param suppliers Multi Futures --> List
* @param Type of source element
* @param Type of supplier's list element
* @param Type of return
* @return Future for final result.
*/
public static Future thenJsonOne(final List list, final String pojo) {
return Future.succeededFuture(To.toUnique(new JsonArray(list), pojo));
}
public static Future thenJsonOne(final T entity, final String pojo) {
return Future.succeededFuture(To.toJson(entity, pojo));
}
public static Future thenMore(final List list, final String pojo) {
return Future.succeededFuture(Envelop.success(To.toArray(list, pojo)));
}
public static Future thenOne(final T entity, final String pojo) {
return Future.succeededFuture(Envelop.success(To.toJson(entity, pojo)));
}
public static Future thenUpsert(final T entity,
final Supplier> supplier) {
return Async.toUpsertFuture(entity, "", supplier, null);
}
public static Future thenUpsert(final T entity,
final Supplier> supplier,
final Function updateFun) {
return Async.toUpsertFuture(entity, "", supplier, updateFun);
}
public static Future thenUpsert(final T entity, final String pojo,
final Supplier> supplier) {
return Async.toUpsertFuture(entity, pojo, supplier, null);
}
public static Future thenUpsert(final T entity, final String pojo,
final Supplier> supplier,
final Function updateFun) {
return Async.toUpsertFuture(entity, pojo, supplier, updateFun);
}
public static Future thenJsonMore(final List list) {
return Future.succeededFuture(To.toArray(list, ""));
}
public static Future thenJsonMore(final List list, final String pojo) {
return Future.succeededFuture(To.toArray(list, pojo));
}
public static Future then(final T entity) {
return Future.succeededFuture(to(entity));
}
// -> Message -> String ( Security )
@Deprecated
public static String getUserID(final Envelop envelop, final String field) {
return In.requestUser(envelop, field);
}
/*
public static String getUserID(final Message message, final String field) {
return In.requestUser(message, field);
}
// -> Message -> UUID ( Security )
public static UUID getUserUUID(final Message message, final String field) {
return UUID.fromString(getUserID(message, field));
}
public static UUID getUserUUID(final Envelop envelop, final String field) {
return UUID.fromString(getUserID(envelop, field));
}*/
// -> Message -> Session ( Key )
/*
public static Object getSession(final Message message, final String field) {
return In.requestSession(message, field);
}
public static Object getSession(final Envelop envelop, final String field) {
return In.requestSession(envelop, field);
}*/
public static Future toFuture(final T entity, final Supplier defaultFun, final Function actualFun) {
return null == entity ? Future.succeededFuture(defaultFun.get()) : Future.succeededFuture(actualFun.apply(entity));
}
// ---------------------- If/Else Future ----------------------------
public static Future toFuture(final Supplier> caseLine) {
return Fn.future(caseLine);
}
public static Future toFuture(final Actuator executor, final Supplier> caseLine) {
return Fn.future(executor, caseLine);
}
// -> JsonArray -> Envelop ( To JsonObject, Result length must be 1 )
public static Envelop toOne(final JsonArray array) {
return Envelop.success(To.toUnique(array, ""));
}
// -> List -> JsonObject ( Result length must be 1 )
public static JsonObject toUnique(final List list) {
return To.toUnique(Ux.toArray(list), "");
}
public static JsonObject toUnique(final List list, final String pojo) {
return To.toUnique(Ux.toArray(list), pojo);
}
// -> JsonArray -> JsonObject ( Result length must be 1 )
public static JsonObject toUnique(final JsonArray array) {
return To.toUnique(array, "");
}
// ---------------------- Web Error Returned --------------------------
// -> WebException direct
public static WebException toError(final Class extends WebException> clazz, final Object... args) {
return To.toError(clazz, args);
}
public static void timer(final Class> clazz, final Actuator actuator) {
Debug.timer(clazz, actuator);
}
public static T timer(final Class> clazz, final Supplier supplier) {
return Debug.timer(clazz, supplier);
}
// -> Message -> JsonObject ( Interface mode )
public static JsonObject getJson3(final Envelop envelop) {
return In.request(envelop, 3, JsonObject.class);
}
public static JsonObject fromEnvelop3(final Envelop envelop, final String pojo) {
return From.fromJson(Ux.getJson3(envelop), pojo);
}
public static T fromEnvelop3(final Envelop envelop, final Class clazz, final String pojo) {
return From.fromJson(getJson3(envelop), clazz, pojo);
}
// -> Message -> Integer ( Interface mode )
public static Integer getInteger3(final Envelop envelop) {
return In.request(envelop, 3, Integer.class);
}
// -> Message -> Long ( Interface mode )
public static Long getLong3(final Envelop envelop) {
return In.request(envelop, 3, Long.class);
}
// -> Message -> T ( Interface mode )
public static T getT3(final Envelop envelop, final Class clazz) {
return In.request(envelop, 3, clazz);
}
// ---------------------- Request Data Ending --------------------------
public static Future rxContainer(final Refer container, final E entity) {
return Functions.fnSupplier(container, entity, null);
}
public static Future rxContainer(final Refer container, final E entity, final Supplier supplier) {
return Functions.fnSupplier(container, entity, supplier);
}
public static Future rxContainer(final Refer container, final E entity, final Consumer consumer) {
return Functions.fnConsumer(container, entity, consumer);
}
public static Future rxContainer(final Refer container, final E entity, final Function function) {
return Functions.fnConsumer(container, entity, item -> function.apply((T) item));
}
public static Future rxContainer(final Refer container, final E entity, final T target) {
return Functions.fnSupplier(container, entity, () -> target);
}
// -> Message -> String ( Interface mode )
public static String getString3(final Envelop envelop) {
return In.request(envelop, 3, String.class);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy