@Test public void testMultipleSplits() { List<String> result = Split.split("a${hello}${hella}d"); assertEquals(4, result.size()); assertEquals("a", result.get(0)); assertEquals("${hello}", result.get(1)); assertEquals("${hella}", result.get(2)); assertEquals("d", result.get(3)); }
@Nonnull public static List<String> split(@Nullable final String value) { List<String> result = new ArrayList<String>(); if (value == null) { return result; } String remaining = value; int startIdx = 0; while (true) { remaining = remaining.substring(startIdx); if (remaining.length() == 0) { break; } boolean parsingKey = remaining.startsWith(BEGIN_KEY); int endIdx = findEndIdx(remaining, parsingKey); if (endIdx == -1) { result.add(remaining); break; } if (parsingKey) { result.add(remaining.substring(0, endIdx + 1)); startIdx = endIdx + 1; } else { result.add(remaining.substring(0, endIdx)); startIdx = endIdx; } } return result; }
Split { @Nonnull public static List<String> split(@Nullable final String value) { List<String> result = new ArrayList<String>(); if (value == null) { return result; } String remaining = value; int startIdx = 0; while (true) { remaining = remaining.substring(startIdx); if (remaining.length() == 0) { break; } boolean parsingKey = remaining.startsWith(BEGIN_KEY); int endIdx = findEndIdx(remaining, parsingKey); if (endIdx == -1) { result.add(remaining); break; } if (parsingKey) { result.add(remaining.substring(0, endIdx + 1)); startIdx = endIdx + 1; } else { result.add(remaining.substring(0, endIdx)); startIdx = endIdx; } } return result; } }
Split { @Nonnull public static List<String> split(@Nullable final String value) { List<String> result = new ArrayList<String>(); if (value == null) { return result; } String remaining = value; int startIdx = 0; while (true) { remaining = remaining.substring(startIdx); if (remaining.length() == 0) { break; } boolean parsingKey = remaining.startsWith(BEGIN_KEY); int endIdx = findEndIdx(remaining, parsingKey); if (endIdx == -1) { result.add(remaining); break; } if (parsingKey) { result.add(remaining.substring(0, endIdx + 1)); startIdx = endIdx + 1; } else { result.add(remaining.substring(0, endIdx)); startIdx = endIdx; } } return result; }  }
Split { @Nonnull public static List<String> split(@Nullable final String value) { List<String> result = new ArrayList<String>(); if (value == null) { return result; } String remaining = value; int startIdx = 0; while (true) { remaining = remaining.substring(startIdx); if (remaining.length() == 0) { break; } boolean parsingKey = remaining.startsWith(BEGIN_KEY); int endIdx = findEndIdx(remaining, parsingKey); if (endIdx == -1) { result.add(remaining); break; } if (parsingKey) { result.add(remaining.substring(0, endIdx + 1)); startIdx = endIdx + 1; } else { result.add(remaining.substring(0, endIdx)); startIdx = endIdx; } } return result; }  static boolean containsKey(@Nullable final String value); @Nonnull static List<String> split(@Nullable final String value); @Nonnull static String join(@Nonnull final List<String> parts); }
Split { @Nonnull public static List<String> split(@Nullable final String value) { List<String> result = new ArrayList<String>(); if (value == null) { return result; } String remaining = value; int startIdx = 0; while (true) { remaining = remaining.substring(startIdx); if (remaining.length() == 0) { break; } boolean parsingKey = remaining.startsWith(BEGIN_KEY); int endIdx = findEndIdx(remaining, parsingKey); if (endIdx == -1) { result.add(remaining); break; } if (parsingKey) { result.add(remaining.substring(0, endIdx + 1)); startIdx = endIdx + 1; } else { result.add(remaining.substring(0, endIdx)); startIdx = endIdx; } } return result; }  static boolean containsKey(@Nullable final String value); @Nonnull static List<String> split(@Nullable final String value); @Nonnull static String join(@Nonnull final List<String> parts);  }