KeyValueUtils { public static Map<String, String> removeKeySuffix(Map<String, String> keyValues, int suffixLength) { Map<String, String> map = new HashMap<>(); for(Map.Entry<String, String> entry : keyValues.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); String newKey = key.substring(0, key.length() - suffixLength); map.put(newKey, value); } return map; }  static Map<String, String> filterWithKeyIgnoreCaseEndsWith(Properties properties, String suffix); static Map<String, String> filterWithKeyIgnoreCaseEndsWith(Map<String, String> keyValues, String suffix); static Map<String, String> removeKeySuffix(Map<String, String> keyValues, int suffixLength);  }
@Test public void testRemoveKeySuffix() { Map<String, String> map = new HashMap<>(); map.put("abc_meta", "none"); map.put("234_meta", "none"); map.put("888_meta", "none"); Map<String, String> afterFilter = KeyValueUtils.removeKeySuffix(map, "_meta".length()); for(Map.Entry<String, String> entry : afterFilter.entrySet()) { String key = entry.getKey(); assertFalse(key.endsWith("_meta")); assertFalse(key.contains("_meta")); } }