diff options
author | Keuin <[email protected]> | 2020-04-24 08:48:13 +0800 |
---|---|---|
committer | keuin <[email protected]> | 2020-04-24 08:48:13 +0800 |
commit | 87f5cd97ab22b17a948eb9af1b49a0b1e777048d (patch) | |
tree | 26513b679f0f5327fed4f7233731430a40993aa6 /src/main/java/com/keuin/kbackupfabric/data/PendingOperation.java | |
parent | 8f3951090a8b1f385d1e2ab1319497c23fdeb3d8 (diff) |
Added /kb delete <backup_name> for deleting an backup (with auto-complete supported).
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/data/PendingOperation.java')
-rw-r--r-- | src/main/java/com/keuin/kbackupfabric/data/PendingOperation.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/data/PendingOperation.java b/src/main/java/com/keuin/kbackupfabric/data/PendingOperation.java new file mode 100644 index 0000000..8f7490c --- /dev/null +++ b/src/main/java/com/keuin/kbackupfabric/data/PendingOperation.java @@ -0,0 +1,41 @@ +package com.keuin.kbackupfabric.data; + +public class PendingOperation { + private final PendingOperationType operationType; + private final String backupName; + + public PendingOperation(PendingOperationType operationType, String backupName) { + this.operationType = operationType; + this.backupName = backupName; + } + + public static PendingOperation deleteOperation(String backupName) { + return new PendingOperation(PendingOperationType.DELETE, backupName); + } + + public static PendingOperation restoreOperation(String backupName) { + return new PendingOperation(PendingOperationType.RESTORE_TO, backupName); + } + + public boolean isDelete() { + return operationType == PendingOperationType.DELETE; + } + + public boolean isRestore() { + return operationType == PendingOperationType.RESTORE_TO; + } + + public String getBackupName() { + return backupName; + } + + @Override + public String toString() { + String op = "operation"; + if (isDelete()) + op = "deletion"; + if (isRestore()) + op = "restoration"; + return String.format("%s on backup %s", op, getBackupName()); + } +} |