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

org.mockserver.matchers.HashMapMatcher Maven / Gradle / Ivy

There is a newer version: 5.15.0
Show newest version
package org.mockserver.matchers;

import org.mockserver.collections.CaseInsensitiveRegexHashMap;
import org.mockserver.model.KeyAndValue;

import java.util.List;

/**
 * @author jamesdbloom
 */
public class HashMapMatcher extends NotMatcher> {
    private final CaseInsensitiveRegexHashMap hashMap;

    public HashMapMatcher(CaseInsensitiveRegexHashMap hashMap) {
        this.hashMap = hashMap;
    }

    public boolean matches(List values) {
        boolean result = false;

        if (hashMap == null) {
            result = true;
        } else if (KeyAndValue.toHashMap(values).containsAll(hashMap)) {
            result = true;
        } else {
            logger.trace("Map [{}] is not a subset of [{}]", this.hashMap, KeyAndValue.toHashMap(values));
        }

        return reverseResultIfNot(result);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy