コード例 #1
0
 @Test
 public void toMap() {
   String tokens = "1:Ted|2:Mary";
   MutableMap<String, String> results = StringIterate.tokensToMap(tokens);
   Verify.assertSize(2, results);
   Verify.assertContainsKeyValue("1", "Ted", results);
   Verify.assertContainsKeyValue("2", "Mary", results);
 }
コード例 #2
0
 @Test
 public void toMapWithFunctions() {
   String tokens = "1:Ted|2:Mary";
   Function<String, String> stringPassThruFunction = Functions.getPassThru();
   MutableMap<Integer, String> results =
       StringIterate.tokensToMap(
           tokens, "|", ":", Functions.getStringToInteger(), stringPassThruFunction);
   Verify.assertSize(2, results);
   Verify.assertContainsKeyValue(1, "Ted", results);
   Verify.assertContainsKeyValue(2, "Mary", results);
 }