com.noenv.wiremongo.mapping.find.FindBase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vertx-wiremongo Show documentation
Show all versions of vertx-wiremongo Show documentation
Lightweight mongo mocking for Vert.x
package com.noenv.wiremongo.mapping.find;
import com.noenv.wiremongo.command.find.FindBaseCommand;
import com.noenv.wiremongo.mapping.WithQuery;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import java.util.List;
import java.util.stream.Collectors;
public abstract class FindBase> extends WithQuery, U, C> {
protected FindBase() {
this("find");
}
protected FindBase(String method) {
super(method);
}
protected FindBase(JsonObject json) {
super(json);
}
@Override
public C returns(final List response) {
return super.stub(c -> null == response ? null : response.stream().map(JsonObject::copy).collect(java.util.stream.Collectors.toList()));
}
@Override
protected List parseResponse(Object jsonValue) {
return ((JsonArray) jsonValue).stream()
.map(JsonObject.class::cast)
.collect(Collectors.toList());
}
}