@Override public boolean equal(T actual, T expected) { String actualString = actual.toString(); String expectedString = expected.toString(); try { Pattern pattern = isStaticPattern() ? expectedPattern : Pattern .compile(expectedString); if (!pattern.matcher(actualString).matches()) { throw new ValueMatcherException(getPatternType() + " expected pattern did not match value", pattern.toString(), actualString); } } catch (PatternSyntaxException e) { throw new ValueMatcherException(getPatternType() + " expected pattern invalid: " + e.getMessage(), e, expectedString, actualString); } return true; }
private String getPatternType() { return isStaticPattern()? "Constant": "Dynamic"; } }
private String getPatternType() { return isStaticPattern()? "Constant": "Dynamic"; } }
@Override public boolean equal(T actual, T expected) { String actualString = actual.toString(); String expectedString = expected.toString(); try { Pattern pattern = isStaticPattern() ? expectedPattern : Pattern .compile(expectedString); if (!pattern.matcher(actualString).matches()) { throw new ValueMatcherException(getPatternType() + " expected pattern did not match value", pattern.toString(), actualString); } } catch (PatternSyntaxException e) { throw new ValueMatcherException(getPatternType() + " expected pattern invalid: " + e.getMessage(), e, expectedString, actualString); } return true; }