### Question:
PatternCorrector implements ValueCorrector<String> { @Override public String correct(String value) { if (Strings.isNullOrEmpty(value)) return null; Matcher matcher = _pattern.matcher(value); if (matcher.matches()) return value; else return null; } PatternCorrector(Pattern pattern); @Override String correct(String value);  }### Answer:
@Test public void ipTest() { PatternCorrector pc = new PatternCorrector(Patterns.IP_ADDRESS); assertNotNull(pc.correct("10.10.199.255")); assertNull(pc.correct("10.10.199.256")); assertNull(pc.correct("10.10.199.*")); assertNull(pc.correct("10.10.19")); assertNull(pc.correct("1.10.19.test")); assertNull(pc.correct(null)); assertNull(pc.correct("")); assertNull(pc.correct(" ")); }
@Test public void mailTest() { PatternCorrector pc = new PatternCorrector(Patterns.MAIL_ADDRESS); assertNotNull(pc.correct("chennan@ctrip.com")); assertNull(pc.correct("chennan")); assertNull(pc.correct("@")); assertNull(pc.correct("ctrip.com")); assertNull(pc.correct("@ctrip.com")); assertNull(pc.correct(null)); assertNull(pc.correct("")); assertNull(pc.correct(" ")); }