com.noenv.wiremongo.mapping.replace.WithReplace 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.replace;
import com.noenv.wiremongo.command.Command;
import com.noenv.wiremongo.command.replace.WithReplaceCommand;
import com.noenv.wiremongo.mapping.WithQuery;
import com.noenv.wiremongo.matching.Matcher;
import io.vertx.core.json.JsonObject;
import static com.noenv.wiremongo.matching.EqualsMatcher.equalTo;
public abstract class WithReplace> extends WithQuery {
private Matcher replace;
public WithReplace(String method) {
super(method);
}
public WithReplace(JsonObject json) {
super(json);
replace = Matcher.create(json.getJsonObject("replace"));
}
@Override
public boolean matches(Command cmd) {
if (!super.matches(cmd)) {
return false;
}
if (!(cmd instanceof WithReplaceCommand)) {
return false;
}
WithReplaceCommand c = (WithReplaceCommand) cmd;
return replace == null || replace.matches(c.getReplace());
}
public C withReplace(JsonObject replace) {
return withReplace(equalTo(replace));
}
public C withReplace(Matcher replace) {
this.replace = replace;
return self();
}
}