use of services.moleculer.eventbus.Groups in project moleculer-java by moleculer-java.
the class CommonUtils method parseParams.
// --- PARSE CALL / BROADCAST PARAMS ---
public static final ParseResult parseParams(Object[] params) {
Tree data = null;
CallOptions.Options opts = null;
Groups groups = null;
if (params != null) {
if (params.length == 1) {
if (params[0] instanceof Tree) {
data = (Tree) params[0];
} else {
data = new CheckedTree(params[0]);
}
} else {
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
String prev = null;
Object value;
for (int i = 0; i < params.length; i++) {
value = params[i];
if (prev == null) {
if (!(value instanceof String)) {
if (value instanceof CallOptions.Options) {
opts = (CallOptions.Options) value;
continue;
}
if (value instanceof Groups) {
groups = (Groups) value;
continue;
}
i++;
throw new IllegalArgumentException("Parameter #" + i + " (\"" + value + "\") must be String, Context, Groups, or CallOptions!");
}
prev = (String) value;
continue;
}
map.put(prev, value);
prev = null;
}
data = new Tree(map);
}
}
return new ParseResult(data, opts, groups);
}
Aggregations