io.vertx.up.unity.JooqResult Maven / Gradle / Ivy
package io.vertx.up.unity;
import io.vertx.core.json.JsonArray;
import io.vertx.up.atom.Mojo;
import io.vertx.up.util.Ut;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
/*
* Jooq Result for ( DataRegion Needed )
* 1) `projection` to do filter and remove un-used columns
*/
@SuppressWarnings("all")
class JooqResult {
static List toResult(final List list, final JsonArray projection, final Mojo mojo) {
/*
* convert projection to field
*/
if (Objects.nonNull(projection) && !projection.isEmpty()) {
final Set filters = new HashSet<>();
if (Objects.nonNull(mojo)) {
/* Pojo file bind */
projection.stream()
.filter(Objects::nonNull)
.map(field -> (String) field)
.map(field -> mojo.getRevert().get(field))
.forEach(filters::add);
} else {
/* No Pojo file */
filters.addAll(projection.getList());
}
/* Clear field */
filters.forEach(filtered -> list.forEach(entity -> Ut.field(entity, filtered, null)));
}
return list;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy