Sharder { public static String buildShardKey(List<String> shardKey, Map<String, String> values) { StringBuilder shardBuilder = new StringBuilder(); for (String key : shardKey) { if (shardBuilder.length() != 0) { shardBuilder.append(','); } shardBuilder.append(httpHeaderEscape(key)); shardBuilder.append(':'); shardBuilder.append(httpHeaderEscape(values.get(key))); } return shardBuilder.toString(); }  static String buildShardKey(List<String> shardKey, Map<String, String> values); static String httpHeaderEscape(String key); static final String SHARD_KEY; }
@Test public void shardKeyTest() { String key = Sharder.buildShardKey(ImmutableList.of("what", "status"), ImmutableMap.of("what","balls","status","tripping","site","lon")); assertEquals("what:balls,status:tripping", key); }