}
}
+ @FunctionalInterface
+ public static interface FileOperation {
+ IOperation<Boolean, IOException> perform(File file);
+
+ default void perform(File... files) {
+ for (File f : files)
+ perform(f);
+ }
+ }
+
+ public static class DeleteOperation implements FileOperation {
+ private final FileService service;
+ private final DeleteOption[] options;
+
+ public DeleteOperation(FileService service, DeleteOption... options) {
+ this.service = service;
+ this.options = options;
+ }
+
+ @Override
+ public IOperation<Boolean, IOException> perform(File file) {
+ return service.scheduleDeleteIfExists(file, options);
+ }
+ }
+
/**
* Schedules a file to be deleted at some point in the future when the
* system allows it to be deleted if ever.
*/
IOperation<Boolean, IOException> scheduleDeleteIfExists(File file, DeleteOption... options);
+ /**
+ * @param options
+ * the deletion options to be used by the returned FileOperation
+ * @return a FileOperation that runs
+ * {@link #scheduleDeleteIfExists(File, DeleteOption...)} for any
+ * files given to it
+ * @since 1.28.0
+ */
+ default FileOperation deleteOperation(DeleteOption... options) {
+ return new DeleteOperation(this, options);
+ }
+
}