
com.noenv.wiremongo.matching.EqualsMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vertx-wiremongo Show documentation
Show all versions of vertx-wiremongo Show documentation
Lightweight mongo mocking for Vert.x
package com.noenv.wiremongo.matching;
import io.vertx.ext.mongo.BulkWriteOptions;
import io.vertx.ext.mongo.IndexOptions;
import java.util.Objects;
public class EqualsMatcher implements Matcher {
private final T value;
private EqualsMatcher(T value) {
this.value = value;
}
@Override
public boolean matches(T other) {
//TODO: remove with vertx 4.0 (https://github.com/vert-x3/vertx-mongo-client/pull/168)
if (other instanceof IndexOptions && value instanceof IndexOptions) {
return Objects.equals(((IndexOptions)value).toJson(), ((IndexOptions)other).toJson());
}
//TODO: remove with vertx 4.0 (https://github.com/vert-x3/vertx-mongo-client/pull/169)
if (other instanceof BulkWriteOptions && value instanceof BulkWriteOptions) {
return Objects.equals(((BulkWriteOptions)value).toJson(), ((BulkWriteOptions)other).toJson());
}
return Objects.equals(value, other);
}
public static EqualsMatcher equalTo(T value) {
return new EqualsMatcher<>(value);
}
public static Matcher notEqualTo(T value) {
return o -> !equalTo(value).matches(o);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy