PrefixUrlRewrite implements ResolverRewriteDirective { @Override public String rewrite(String href) { return replacement + href.substring(prefix.length()); } PrefixUrlRewrite(String prefix, String replacement); @Override boolean appliesTo(String href); @Override String rewrite(String href); @Override Object getKey();  }
@Test public void testRewrite() throws Exception { final String replacement = "replacement:"; final PrefixUrlRewrite directive = new PrefixUrlRewrite("prefix", replacement); assertTrue(directive.appliesTo("prefix--hi")); assertFalse(directive.appliesTo("nn--hi")); assertEquals(replacement + "--hi", directive.rewrite("prefix--hi")); }