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

com.noenv.wiremongo.mapping.stream.WithStreamQuery Maven / Gradle / Ivy

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

import com.noenv.wiremongo.command.Command;
import com.noenv.wiremongo.command.stream.WithStreamQueryCommand;
import com.noenv.wiremongo.matching.Matcher;
import io.vertx.core.json.JsonObject;

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


public abstract class WithStreamQuery> extends WithStream {

  private Matcher query;

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

  public WithStreamQuery(JsonObject json) {
    super(json);
    query = Matcher.create(json.getJsonObject("query"));
  }

  @Override
  public boolean matches(Command cmd) {
    if (!super.matches(cmd)) {
      return false;
    }
    if (!(cmd instanceof WithStreamQueryCommand)) {
      return false;
    }
    WithStreamQueryCommand c = (WithStreamQueryCommand) cmd;
    return query == null || query.matches(c.getQuery());
  }

  public C withQuery(JsonObject query) {
    return withQuery(equalTo(query));
  }

  public C withQuery(Matcher query) {
    this.query = query;
    return self();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy