org.mockserver.matchers.BinaryMatcher 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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
/**
* @author jamesdbloom
*/
public class BinaryMatcher extends BodyMatcher implements Matcher {
private static Logger logger = LoggerFactory.getLogger(BinaryMatcher.class);
private final byte[] matcher;
public BinaryMatcher(byte[] matcher) {
this.matcher = matcher;
}
public boolean matches(byte[] matched) {
boolean result = false;
if (matcher == null || matcher.length == 0 || Arrays.equals(matcher, matched)) {
result = true;
}
if (!result) {
logger.trace("Failed to perform binary match [{}] with [{}] because {}", matched);
}
return result;
}
@Override
public String[] fieldsExcludedFromEqualsAndHashCode() {
return new String[]{"logger"};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy