@Test public void expandSimple() { PathMapping mappings[] = PathMapping.parse("../third_party/vectorial/include/..."); assertThat(mappings).hasLength(21); }
public static PathMapping[] parse(@NotNull String text) { List<PathMapping> result = new ArrayList<>(); String[] mappings = text.split("\\|"); for (String mapping : mappings) { String[] fromTo = mapping.split("->"); if (fromTo.length == 1) { if (fromTo[0].endsWith("/...")) { File baseFolder = new File(fromTo[0].substring(0, fromTo[0].length() - 4)); for (File from : FileUtils.listFileTree(baseFolder)) { File to = new File(from.getPath().substring(baseFolder.getPath().length() + 1)); result.add(new PathMapping(from, to)); } } else { result.add(new PathMapping( new File(fromTo[0].trim()), new File(new File(fromTo[0].trim()).getName()))); } } else if (fromTo.length == 2) { result.add(new PathMapping( new File(fromTo[0].trim()), new File( fromTo[1].trim()))); } } return result.toArray(new PathMapping[result.size()]); }
PathMapping { public static PathMapping[] parse(@NotNull String text) { List<PathMapping> result = new ArrayList<>(); String[] mappings = text.split("\\|"); for (String mapping : mappings) { String[] fromTo = mapping.split("->"); if (fromTo.length == 1) { if (fromTo[0].endsWith("/...")) { File baseFolder = new File(fromTo[0].substring(0, fromTo[0].length() - 4)); for (File from : FileUtils.listFileTree(baseFolder)) { File to = new File(from.getPath().substring(baseFolder.getPath().length() + 1)); result.add(new PathMapping(from, to)); } } else { result.add(new PathMapping( new File(fromTo[0].trim()), new File(new File(fromTo[0].trim()).getName()))); } } else if (fromTo.length == 2) { result.add(new PathMapping( new File(fromTo[0].trim()), new File( fromTo[1].trim()))); } } return result.toArray(new PathMapping[result.size()]); } }
PathMapping { public static PathMapping[] parse(@NotNull String text) { List<PathMapping> result = new ArrayList<>(); String[] mappings = text.split("\\|"); for (String mapping : mappings) { String[] fromTo = mapping.split("->"); if (fromTo.length == 1) { if (fromTo[0].endsWith("/...")) { File baseFolder = new File(fromTo[0].substring(0, fromTo[0].length() - 4)); for (File from : FileUtils.listFileTree(baseFolder)) { File to = new File(from.getPath().substring(baseFolder.getPath().length() + 1)); result.add(new PathMapping(from, to)); } } else { result.add(new PathMapping( new File(fromTo[0].trim()), new File(new File(fromTo[0].trim()).getName()))); } } else if (fromTo.length == 2) { result.add(new PathMapping( new File(fromTo[0].trim()), new File( fromTo[1].trim()))); } } return result.toArray(new PathMapping[result.size()]); } private  PathMapping(File from, File to); }
PathMapping { public static PathMapping[] parse(@NotNull String text) { List<PathMapping> result = new ArrayList<>(); String[] mappings = text.split("\\|"); for (String mapping : mappings) { String[] fromTo = mapping.split("->"); if (fromTo.length == 1) { if (fromTo[0].endsWith("/...")) { File baseFolder = new File(fromTo[0].substring(0, fromTo[0].length() - 4)); for (File from : FileUtils.listFileTree(baseFolder)) { File to = new File(from.getPath().substring(baseFolder.getPath().length() + 1)); result.add(new PathMapping(from, to)); } } else { result.add(new PathMapping( new File(fromTo[0].trim()), new File(new File(fromTo[0].trim()).getName()))); } } else if (fromTo.length == 2) { result.add(new PathMapping( new File(fromTo[0].trim()), new File( fromTo[1].trim()))); } } return result.toArray(new PathMapping[result.size()]); } private  PathMapping(File from, File to); static PathMapping[] parse(@NotNull String text); }
PathMapping { public static PathMapping[] parse(@NotNull String text) { List<PathMapping> result = new ArrayList<>(); String[] mappings = text.split("\\|"); for (String mapping : mappings) { String[] fromTo = mapping.split("->"); if (fromTo.length == 1) { if (fromTo[0].endsWith("/...")) { File baseFolder = new File(fromTo[0].substring(0, fromTo[0].length() - 4)); for (File from : FileUtils.listFileTree(baseFolder)) { File to = new File(from.getPath().substring(baseFolder.getPath().length() + 1)); result.add(new PathMapping(from, to)); } } else { result.add(new PathMapping( new File(fromTo[0].trim()), new File(new File(fromTo[0].trim()).getName()))); } } else if (fromTo.length == 2) { result.add(new PathMapping( new File(fromTo[0].trim()), new File( fromTo[1].trim()))); } } return result.toArray(new PathMapping[result.size()]); } private  PathMapping(File from, File to); static PathMapping[] parse(@NotNull String text); final public File from; final public File to; }