
com.github.dakusui.crest.matcherbuilders.AsMap Maven / Gradle / Ivy
package com.github.dakusui.crest.matcherbuilders;
import com.github.dakusui.crest.core.Printable;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
public class AsMap> extends ObjectMatcherBuilder, SELF> {
public AsMap(Function super I, ? extends Map> function) {
super(function);
}
public AsMap hasEntry(K key, V value) {
return this.check(Printable.predicate(
String.format("hasEntry[%s,%s]", key, value),
map -> map.containsKey(key) && Objects.equals(map.get(key), value)
));
}
public AsMap hasKey(K key) {
return this.check(Printable.predicate(
String.format("hasKey[%s]", key),
map -> map.containsKey(key)
));
}
public AsMap hasValue(V value) {
return this.check(Printable.predicate(
String.format("hasValue[%s]", value),
map -> map.containsValue(value)
));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy