All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.noenv.wiremongo.mapping.remove.RemoveDocumentsWithOptions Maven / Gradle / Ivy

There is a newer version: 4.5.10
Show newest version
package com.noenv.wiremongo.mapping.remove;

import com.noenv.wiremongo.command.Command;
import com.noenv.wiremongo.command.remove.RemoveDocumentsWithOptionsCommand;
import com.noenv.wiremongo.matching.Matcher;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.mongo.WriteOption;

import static com.noenv.wiremongo.matching.EqualsMatcher.equalTo;

@SuppressWarnings("squid:MaximumInheritanceDepth")
public class RemoveDocumentsWithOptions extends RemoveDocumentsBase {

  private Matcher options;

  public RemoveDocumentsWithOptions() {
    super("removeDocumentsWithOptions");
  }

  public RemoveDocumentsWithOptions(JsonObject json) {
    super(json);
    options = Matcher.create(json.getJsonObject("options"), j -> WriteOption.valueOf((String) j), Enum::name);
  }

  @Override
  public boolean matches(Command cmd) {
    if (!super.matches(cmd)) {
      return false;
    }
    if (!(cmd instanceof RemoveDocumentsWithOptionsCommand)) {
      return false;
    }
    RemoveDocumentsWithOptionsCommand c = (RemoveDocumentsWithOptionsCommand) cmd;
    return options == null || options.matches(c.getOptions());
  }

  public RemoveDocumentsWithOptions withOptions(WriteOption options) {
    return withOptions(equalTo(options));
  }

  public RemoveDocumentsWithOptions withOptions(Matcher options) {
    this.options = options;
    return self();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy