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

com.noenv.wiremongo.mapping.collection.CreateCollectionWithOptions Maven / Gradle / Ivy

There is a newer version: 4.5.11
Show newest version
package com.noenv.wiremongo.mapping.collection;

import com.noenv.wiremongo.command.Command;
import com.noenv.wiremongo.command.collection.CreateCollectionWithOptionsCommand;
import com.noenv.wiremongo.matching.JsonMatcher;
import com.noenv.wiremongo.matching.Matcher;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.mongo.CreateCollectionOptions;

public class CreateCollectionWithOptions extends WithCollection {

  private Matcher options;

  public CreateCollectionWithOptions() {
    super("createCollectionWithOptions");
  }

  public CreateCollectionWithOptions(JsonObject json) {
    super(json);
    options = Matcher.create(json.getJsonObject("options"), j -> new CreateCollectionOptions((JsonObject) j), CreateCollectionOptions::toJson);
  }

  @Override
  protected Void parseResponse(Object jsonValue) {
    return null;
  }

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

  public CreateCollectionWithOptions withOptions(CreateCollectionOptions options) {
    return withOptions(JsonMatcher.equalToJson(options.toJson(), CreateCollectionOptions::toJson));
  }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy