summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/PrimitiveBackupFeedback.java
blob: e8844a264c50a68f3cbd585dd2b45211f5913950 (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
package com.keuin.kbackupfabric.operation.backup.feedback;

import static com.keuin.kbackupfabric.backup.BackupFilesystemUtil.getFriendlyFileSizeString;

public class PrimitiveBackupFeedback implements BackupFeedback {
    private final boolean success;
    private final long backupSizeBytes;

    public PrimitiveBackupFeedback(boolean success, long backupSizeBytes) {
        this.success = success;
        this.backupSizeBytes = backupSizeBytes;
    }

    @Override
    public boolean isSuccess() {
        return success;
    }

    public long getBackupSizeBytes() {
        return backupSizeBytes;
    }

    @Override
    public String getFeedback() {
        if (success && backupSizeBytes >= 0)
            return String.format("File size: %s.", getFriendlyFileSizeString(backupSizeBytes));
        else
            return "";
    }
}