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

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 AsObject, SELF> {
  public AsMap(Function> 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