use of org.webpieces.util.futures.XFuture in project webpieces by deanhiller.
the class ParamToObjectTranslatorImpl method fillBeanIn.
private XFuture<Object> fillBeanIn(Object bean, ParamTreeNode tree, RouterRequest req, Method method, Validation validator) {
XFuture<Object> future = XFuture.completedFuture(bean);
for (Map.Entry<String, ParamNode> entry : tree.entrySet()) {
String key = entry.getKey();
ParamNode value = entry.getValue();
Field field = findBeanFieldType(bean.getClass(), key, new ArrayList<>());
FieldMeta nextFieldMeta = new FieldMeta(field);
// Here, if there are any lookups(doubtful!!), they would all be done in parallel....
XFuture<Object> translated = translate(req, method, value, nextFieldMeta, validator);
future = future.thenCompose(b -> translated).thenApply(translatedValue -> {
nextFieldMeta.setValueOnBean(bean, translatedValue);
return bean;
});
}
return future;
}
Aggregations