Interface BackupStrategy


public interface BackupStrategy

Provides a simple but automated backup strategy to the acx tool.

General usage pattern is as follows:

// Only save if there are changes.
if (disk.getSource().hasChanged()) {
    backupStrategy.backup(disk.getFilename());
    disk.save();
}

To create a BackupStrategy in a consistent manner, use the #create method:

BackupStrategy backupStrategy = BackupStrategy.create("bak");

If using in a context where a backup is no expected (as in a new file, or a "save as" situation), simply use BackupStrategy.none().

The coding is as follows:

  • null or blank (""): Returns an ineffective strategy. (No branches in code.)
  • bak: Returns a backup strategy that renames the existing file from name.dsk to name.dsk.bak, overwriting any existing files.
  • The default strategy is to assume the value is a directory, which will be created, and make a copy of the file into this directory.
See Also: