ParamMap extends CollectionMap<Object, Object> { public ParamMap addMapWithFilter(Map map, String...prefixs){ if(map==null || map.isEmpty()) return this; for(Map.Entry entry : (Set<Map.Entry>)map.entrySet()){ if(matchPrefix(entry.getKey().toString(), prefixs)) continue; Object val = entry.getValue(); Object[] values = null; if(val instanceof Collection){ values = (Object[])((Collection<Object>)val).toArray(); }else if(val instanceof Object[]){ values = (Object[]) val; }else{ values = new Object[]{val}; } for(Object v : values){ putElement(entry.getKey(), v); } } return this; } ParamMap();  ParamMap(Map<Object, Collection<Object>> map);  ParamMap(String paramStr);  ParamMap(String paramStr, Map<Object, Collection<Object>> map); ParamMap subtract(Map<Object, Collection<Object>> map); ParamMap addWithFilter(Map<Object, Collection<Object>> map, String...prefixs); ParamMap filter(String...patterns); ParamMap addMapWithFilter(Map map, String...prefixs); String toParamString();  }
@Test public void testFilterParams(){ ParamMap map1 = new ParamMap("aa=aa-value&bb=bb-value"); Assert.assertEquals("aa-value", map1.getFirstValue("aa")); Assert.assertEquals("bb-value", map1.getFirstValue("bb")); ParamMap addMap = new ParamMap(); addMap.putElement("dd", "dd-value"); addMap.putElement("test-ee", "testee-value"); addMap.putElement("test-dd", "testdd-value"); addMap.putElement("aa-test-dd", "testdd-value"); map1.addMapWithFilter(addMap, "*test*"); System.out.println("testFilterParams map1:" + map1); Assert.assertEquals("{aa=[aa-value], bb=[bb-value], dd=[dd-value]}", map1.toString()); }