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