@Test public void flattenAndEscapeMultipleElementListWithBackslashesTest() { String[] singleElementList = new String[]{"some\\text", "another text"}; assertEquals("Empty collection should produce empty String", "some\\\\text,another text", PatchingConversions.flattenAndEscape(Arrays.asList(singleElementList))); }
public static String flattenAndEscape(List<String> paths) { if (paths == null) { throw new IllegalArgumentException("Argument paths must be provided"); } StringBuilder sb = new StringBuilder(); for (String p : paths) { if (sb.length() > 0) { sb.append(","); } sb.append(p.replaceAll("\\\\", "\\\\\\\\")); } return sb.toString(); }
PatchingConversions { public static String flattenAndEscape(List<String> paths) { if (paths == null) { throw new IllegalArgumentException("Argument paths must be provided"); } StringBuilder sb = new StringBuilder(); for (String p : paths) { if (sb.length() > 0) { sb.append(","); } sb.append(p.replaceAll("\\\\", "\\\\\\\\")); } return sb.toString(); } }
PatchingConversions { public static String flattenAndEscape(List<String> paths) { if (paths == null) { throw new IllegalArgumentException("Argument paths must be provided"); } StringBuilder sb = new StringBuilder(); for (String p : paths) { if (sb.length() > 0) { sb.append(","); } sb.append(p.replaceAll("\\\\", "\\\\\\\\")); } return sb.toString(); } private  PatchingConversions(); }
PatchingConversions { public static String flattenAndEscape(List<String> paths) { if (paths == null) { throw new IllegalArgumentException("Argument paths must be provided"); } StringBuilder sb = new StringBuilder(); for (String p : paths) { if (sb.length() > 0) { sb.append(","); } sb.append(p.replaceAll("\\\\", "\\\\\\\\")); } return sb.toString(); } private  PatchingConversions(); static String flatten(List<String> list); static String flattenAndEscape(List<String> paths); }
PatchingConversions { public static String flattenAndEscape(List<String> paths) { if (paths == null) { throw new IllegalArgumentException("Argument paths must be provided"); } StringBuilder sb = new StringBuilder(); for (String p : paths) { if (sb.length() > 0) { sb.append(","); } sb.append(p.replaceAll("\\\\", "\\\\\\\\")); } return sb.toString(); } private  PatchingConversions(); static String flatten(List<String> list); static String flattenAndEscape(List<String> paths);  }