UriRegexMatcher implements LookupRegistry<T> { @Override public synchronized T lookup(final String path) { Args.notNull(path, "Request path"); final T obj = this.objectMap.get(path); if (obj == null) { for (final Entry<String, Pattern> entry : this.patternMap.entrySet()) { if (entry.getValue().matcher(path).matches()) { return objectMap.get(entry.getKey()); } } } return obj; } UriRegexMatcher(); @Override synchronized void register(final String regex, final T obj); @Override synchronized void unregister(final String regex); @Override synchronized T lookup(final String path); @Override String toString();  }
@Test(expected = NullPointerException.class) public void testLookupInvalidInput() throws Exception { final LookupRegistry<Object> matcher = new UriRegexMatcher<>(); matcher.lookup(null); }