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

com.noenv.wiremongo.mapping.update.WithUpdate Maven / Gradle / Ivy

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

import com.noenv.wiremongo.command.Command;
import com.noenv.wiremongo.command.update.WithUpdateCommand;
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 WithUpdate> extends WithQuery {

  private Matcher update;

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

  public WithUpdate(JsonObject json) {
    super(json);
    update = Matcher.create(json.getJsonObject("update"));
  }

  @Override
  public boolean matches(Command cmd) {
    if (!super.matches(cmd)) {
      return false;
    }
    if (!(cmd instanceof WithUpdateCommand)) {
      return false;
    }
    WithUpdateCommand c = (WithUpdateCommand) cmd;
    return update == null || update.matches(c.getUpdate());
  }

  public C withUpdate(JsonObject update) {
    return withUpdate(equalTo(update));
  }

  public C withUpdate(Matcher update) {
    this.update = update;
    return self();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy