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

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

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

import org.mockserver.collections.CaseInsensitiveRegexMultiMap;
import org.mockserver.model.EqualsHashCodeToString;
import org.mockserver.model.KeyToMultiValue;

import java.util.List;

/**
 * @author jamesdbloom
 */
public class MapMatcher extends EqualsHashCodeToString implements Matcher> {
    private final CaseInsensitiveRegexMultiMap multiMap;

    public MapMatcher(CaseInsensitiveRegexMultiMap multiMap) {
        this.multiMap = multiMap;
    }

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

        if (KeyToMultiValue.toMultiMap(values).containsAll(multiMap)) {
            result = true;
        } else {
            logger.trace("Map [{}] is not a subset of [{}]", this.multiMap, KeyToMultiValue.toMultiMap(values));
        }

        return result;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy