RegexDescriptor extends AbstractRegisteredItem { public boolean matches(String text) { return pattern.matcher(text).matches(); } private  RegexDescriptor(String theId, String theRegex, String theExample, String theDescription); static Map<String, RegexDescriptor> asMap(RegexDescriptor ...theDescriptors); @Override boolean equals(Object other); @Override int hashCode(); boolean matches(String text); final String regex; final String example; static final RegexDescriptor IPAddress; static final RegexDescriptor Hostname; static final RegexDescriptor EMailAddress; static final RegexDescriptor IPV4; static final Map<String, RegexDescriptor> ALL; }
@Test public void matches() { for (RegexDescriptor rd : RegexDescriptor.ALL.values()) { assertTrue(rd.matches(rd.example)); } }