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

com.github.tomakehurst.wiremock.matching.NegativeRegexPattern Maven / Gradle / Ivy

package com.github.tomakehurst.wiremock.matching;

import com.fasterxml.jackson.annotation.JsonProperty;

public class NegativeRegexPattern extends AbstractRegexPattern {

    public NegativeRegexPattern(@JsonProperty("doesNotMatch") String regex) {
        super(regex);
    }

    public String getDoesNotMatch() {
        return expectedValue;
    }

    @Override
    public MatchResult match(String value) {
        return invert(super.match(value));
    }

    private MatchResult invert(final MatchResult matchResult) {
        return new MatchResult() {

            @Override
            public boolean isExactMatch() {
                return !matchResult.isExactMatch();
            }

            @Override
            public double getDistance() {
                return 1.0 - matchResult.getDistance();
            }
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy