/** * Delete everything recursively * * @param path */ public static void recursiveDelete(Path path) throws IOException { logger.debug("Deleting %s", path); final Iterator<Path> it = Files.list(path).iterator(); while (it.hasNext()) { final Path entry = it.next(); logger.debug("Considering " + entry); if (Files.isDirectory(entry)) { recursiveDelete(entry); } else { Files.delete(entry); } } // Deleting self Files.delete(path); }
@Expose(context = true) public void sort(JavaScriptContext jcx, NativeFunction f) { LOGGER.debug("Sorting list"); Collections.sort( object, (a, b) -> { final double result = (Double) f.call(jcx.context(), jcx.scope(), null, new Object[] {a, b}); if (result > 0) return 1; if (result < 0) return -1; return 0; }); }