You can use makeString()
in Eclipse Collections.
MutableMap<String, String> testMap = new UnifiedMap<String, String>();
testMap.put("key1", "val1");
testMap.put("key2", "val2");
String commaAndSpace = testMap.makeString();
Assert.assertTrue(commaAndSpace.equals("val1, val2")
|| commaAndSpace.equals("val2, val1"));
String comma = testMap.makeString(",");
Assert.assertTrue(comma.equals("val1,val2")
|| comma.equals("val2,val1"));
If you cannot convert your Map
to an Eclipse Collections type, you can use MapAdapter
.
MapAdapter.adapt(testMap).makeString();
Note: I am a committer for Eclipse collections.