diff options
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/PrimitiveBackupFeedback.java')
-rw-r--r-- | src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/PrimitiveBackupFeedback.java | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/PrimitiveBackupFeedback.java b/src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/PrimitiveBackupFeedback.java index 094438c..0d99cf5 100644 --- a/src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/PrimitiveBackupFeedback.java +++ b/src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/PrimitiveBackupFeedback.java @@ -3,12 +3,23 @@ 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; + private final long backupSizeBytes; // if success==false, this is invalid + private final String message; // if success==true, this is invalid - public PrimitiveBackupFeedback(boolean success, long backupSizeBytes) { + private PrimitiveBackupFeedback(boolean success, long backupSizeBytes, String message) { this.success = success; this.backupSizeBytes = backupSizeBytes; + this.message = message; + } + + public static PrimitiveBackupFeedback createSuccessFeedback(long backupSizeBytes) { + return new PrimitiveBackupFeedback(true, backupSizeBytes, ""); + } + + public static PrimitiveBackupFeedback createFailFeedback(String message) { + return new PrimitiveBackupFeedback(false, -1, message); } @Override @@ -25,6 +36,6 @@ public class PrimitiveBackupFeedback implements BackupFeedback { if (success && backupSizeBytes >= 0) return String.format("Backup file size: %s.", getFriendlyFileSizeString(backupSizeBytes)); else - return ""; + return message; } } |