org.mockserver.matchers.BooleanMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockserver-core Show documentation
Show all versions of mockserver-core Show documentation
Functionality used by all MockServer modules for matching and expectations
package org.mockserver.matchers;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.mockserver.logging.MockServerLogger;
import org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString;
/**
* @author jamesdbloom
*/
public class BooleanMatcher extends ObjectWithReflectiveEqualsHashCodeToString implements Matcher {
private static final String[] excludedFields = {"mockServerLogger"};
private final MockServerLogger mockServerLogger;
private final Boolean matcher;
BooleanMatcher(MockServerLogger mockServerLogger, Boolean matcher) {
this.mockServerLogger = mockServerLogger;
this.matcher = matcher;
}
@Override
public boolean matches(final MatchDifference context, Boolean matched) {
boolean result = false;
if (matcher == null) {
result = true;
} else if (matched != null) {
result = matched == matcher;
}
if (!result && context != null) {
context.addDifference(mockServerLogger, "boolean match failed expected:{}found:{}", this.matcher, matched);
}
return result;
}
public boolean isBlank() {
return matcher == null;
}
@Override
@JsonIgnore
public String[] fieldsExcludedFromEqualsAndHashCode() {
return excludedFields;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy