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

com.noenv.wiremongo.mapping.index.CreateIndexBase Maven / Gradle / Ivy

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

import com.noenv.wiremongo.command.Command;
import com.noenv.wiremongo.command.index.CreateIndexBaseCommand;
import com.noenv.wiremongo.mapping.collection.WithCollection;
import com.noenv.wiremongo.matching.Matcher;
import io.vertx.core.json.JsonObject;

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

public abstract class CreateIndexBase> extends WithCollection {

  private Matcher key;

  public CreateIndexBase() {
    this("createIndex");
  }

  public CreateIndexBase(String method) {
    super(method);
  }

  public CreateIndexBase(JsonObject json) {
    super(json);
    key = Matcher.create(json.getJsonObject("key"));
  }

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

  @Override
  public boolean matches(Command cmd) {
    if (!super.matches(cmd)) {
      return false;
    }
    if (!(cmd instanceof CreateIndexBaseCommand)) {
      return false;
    }
    CreateIndexBaseCommand c = (CreateIndexBaseCommand) cmd;
    return key == null || key.matches(c.getKey());
  }

  public C withKey(JsonObject key) {
    return withKey(equalTo(key));
  }

  public C withKey(Matcher key) {
    this.key = key;
    return self();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy