io.vertx.serviceproxy.ProxyUtils Maven / Gradle / Ivy
package io.vertx.serviceproxy;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author Francesco Guardiani @slinkydeveloper
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public class ProxyUtils {
public static List convertToListChar(JsonArray arr) {
List list = new ArrayList<>();
for (Object obj: arr) {
Integer jobj = (Integer)obj;
list.add((char)(int)jobj);
}
return list;
}
public static Set convertToSetChar(JsonArray arr) {
Set set = new HashSet<>();
for (Object obj: arr) {
Integer jobj = (Integer)obj;
set.add((char)(int)jobj);
}
return set;
}
public static Map convertMap(Map map) {
if (map.isEmpty()) {
return (Map) map;
}
Object elem = map.values().stream().findFirst().get();
if (!(elem instanceof Map) && !(elem instanceof List)) {
return (Map) map;
} else {
Function
© 2015 - 2025 Weber Informatics LLC | Privacy Policy