DataTablesParser { protected static Map<String, String[]> unprefix(Map<String, String[]> parametersMap, String prefix) { ImmutableMap.Builder<String, String[]> builder = ImmutableMap.builder(); for (Map.Entry<String, String[]> entry : parametersMap.entrySet()) { String key = entry.getKey(); if (key.startsWith(prefix)) { builder.put(key.substring(prefix.length()), entry.getValue()); } } return builder.build(); }  static DataTablesParameters parametersFrom(PortletRequest request);  }
@Test public void testUnprefix() throws Exception { ImmutableMap.Builder<String, String[]> objectBuilder = ImmutableMap.builder(); objectBuilder.put("pre", new String[]{"1"}); objectBuilder.put("ppre", new String[]{"10"}); objectBuilder.put("prea", new String[]{"5"}); objectBuilder.put("preab", new String[]{"6"}); objectBuilder.put("preac", new String[]{"7"}); Map<String, String[]> map = objectBuilder.build(); Map<String, String[]> unprefixed = DataTablesParser.unprefix(map, "pre"); assertThat(unprefixed.keySet(), containsInAnyOrder("", "a", "ab", "ac")); assertThat(unprefixed, hasEntry("", new String[]{"1"})); assertThat(unprefixed, hasEntry("a", new String[]{"5"})); assertThat(unprefixed, hasEntry("ab", new String[]{"6"})); assertThat(unprefixed, hasEntry("ac", new String[]{"7"})); }