From 821b497a256e0c2825a78c0b070ee3398f79a509 Mon Sep 17 00:00:00 2001 From: Keuin Date: Thu, 21 Jan 2021 12:13:48 +0800 Subject: Fix minor bug in ZipUtil. Do some clean if backup is failed. Small code refactor. --- .../backup/feedback/FailedBackupFeedback.java | 20 +++++++++++++ .../backup/feedback/SuccessBackupFeedback.java | 35 ++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/FailedBackupFeedback.java create mode 100644 src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/SuccessBackupFeedback.java (limited to 'src/main/java/com/keuin/kbackupfabric/operation/backup/feedback') diff --git a/src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/FailedBackupFeedback.java b/src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/FailedBackupFeedback.java new file mode 100644 index 0000000..e7cbbd8 --- /dev/null +++ b/src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/FailedBackupFeedback.java @@ -0,0 +1,20 @@ +package com.keuin.kbackupfabric.operation.backup.feedback; + +public abstract class FailedBackupFeedback implements BackupFeedback { + + private final String message; + + public FailedBackupFeedback(String message) { + this.message = message; + } + + @Override + public boolean isSuccess() { + return false; + } + + @Override + public String getFeedback() { + return message; + } +} diff --git a/src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/SuccessBackupFeedback.java b/src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/SuccessBackupFeedback.java new file mode 100644 index 0000000..dec4e63 --- /dev/null +++ b/src/main/java/com/keuin/kbackupfabric/operation/backup/feedback/SuccessBackupFeedback.java @@ -0,0 +1,35 @@ +package com.keuin.kbackupfabric.operation.backup.feedback; + +import java.util.Objects; + +public abstract class SuccessBackupFeedback implements BackupFeedback { + + private final String message; + + public SuccessBackupFeedback(String successMessage) { + this.message = Objects.requireNonNull(successMessage); + } + + @Override + public boolean isSuccess() { + return true; + } + + @Override + public String getFeedback() { + return message; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SuccessBackupFeedback that = (SuccessBackupFeedback) o; + return message.equals(that.message); + } + + @Override + public int hashCode() { + return Objects.hash(message); + } +} -- cgit v1.2.3