summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/ui/IncrementalBackupInfo.java
diff options
context:
space:
mode:
authorKeuin <[email protected]>2021-01-25 15:25:34 +0800
committerKeuin <[email protected]>2021-01-25 15:25:34 +0800
commit08ac6aaea58b7309ea95a12ca6227a6ca3ce4db5 (patch)
treed305fc23d2cec9935ccb5e5a5390c9d5e54a8726 /src/main/java/com/keuin/kbackupfabric/ui/IncrementalBackupInfo.java
parenta817715ad4f625e355b285d67ee323e8b2006ae4 (diff)
Improve user interaction.
Code refactor.
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/ui/IncrementalBackupInfo.java')
-rw-r--r--src/main/java/com/keuin/kbackupfabric/ui/IncrementalBackupInfo.java68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/ui/IncrementalBackupInfo.java b/src/main/java/com/keuin/kbackupfabric/ui/IncrementalBackupInfo.java
new file mode 100644
index 0000000..89d7fbf
--- /dev/null
+++ b/src/main/java/com/keuin/kbackupfabric/ui/IncrementalBackupInfo.java
@@ -0,0 +1,68 @@
+package com.keuin.kbackupfabric.ui;
+
+import com.keuin.kbackupfabric.backup.incremental.serializer.IncBackupInfoSerializer;
+import com.keuin.kbackupfabric.backup.incremental.serializer.SavedIncrementalBackup;
+import com.keuin.kbackupfabric.operation.backup.method.ConfiguredBackupMethod;
+import net.minecraft.server.MinecraftServer;
+
+import java.io.File;
+import java.io.IOException;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+
+/**
+ * Used in UI part.
+ */
+public class IncrementalBackupInfo implements BackupInfo {
+ private final String name;
+ private final LocalDateTime creationTime;
+ private final long sizeBytes;
+ private final String fileName;
+
+ private IncrementalBackupInfo(String name, LocalDateTime creationTime, long sizeBytes, String fileName) {
+ this.name = name;
+ this.creationTime = creationTime;
+ this.sizeBytes = sizeBytes;
+ this.fileName = fileName;
+ }
+
+ public static IncrementalBackupInfo fromFile(File indexFile) throws IOException {
+ SavedIncrementalBackup info = IncBackupInfoSerializer.fromFile(indexFile);
+ return new IncrementalBackupInfo(
+ info.getBackupName(),
+ info.getBackupTime().withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime(),
+ info.getTotalSizeBytes(),
+ indexFile.getName()
+ );
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public LocalDateTime getCreationTime() {
+ return creationTime;
+ }
+
+ @Override
+ public long getSizeBytes() {
+ return sizeBytes;
+ }
+
+ @Override
+ public String getType() {
+ return "Incremental";
+ }
+
+ @Override
+ public ConfiguredBackupMethod createConfiguredBackupMethod(MinecraftServer server) {
+ throw new RuntimeException("not implemented");
+ }
+
+ @Override
+ public String getBackupFileName() {
+ return fileName;
+ }
+}