summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/data/PendingOperation.java
blob: 8f7490cc8e148ec8e0fe54392bc796d723685adc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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());
    }
}