com.noenv.wiremongo.mapping.find.FindWithOptions 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.Command;
import com.noenv.wiremongo.command.find.FindWithOptionsCommand;
import com.noenv.wiremongo.matching.JsonMatcher;
import com.noenv.wiremongo.matching.Matcher;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.mongo.FindOptions;
@SuppressWarnings("squid:MaximumInheritanceDepth")
public class FindWithOptions extends FindBase {
private Matcher options;
public FindWithOptions() {
super("findWithOptions");
}
public FindWithOptions(JsonObject json) {
super(json);
options = Matcher.create(json.getJsonObject("options"), j -> new FindOptions((JsonObject) j), FindOptions::toJson);
}
@Override
public boolean matches(Command cmd) {
if (!super.matches(cmd)) {
return false;
}
if (!(cmd instanceof FindWithOptionsCommand)) {
return false;
}
FindWithOptionsCommand c = (FindWithOptionsCommand) cmd;
return options == null || options.matches(c.getOptions());
}
public FindWithOptions withOptions(FindOptions options) {
return withOptions(JsonMatcher.equalToJson(options.toJson(), FindOptions::toJson));
}
public FindWithOptions withOptions(Matcher options) {
this.options = options;
return self();
}
}