summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/backup/incremental/serializer/SavedIncBackupV0.java
blob: 8b4a4a16d1b2c9c71ecff8640c8b685392216f43 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.keuin.kbackupfabric.backup.incremental.serializer;

import com.keuin.kbackupfabric.backup.incremental.ObjectCollection2;
import com.keuin.kbackupfabric.backup.name.BackupFileNameEncoder;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Objects;

/**
 * The old-style incremental backup. Just to keep backward compatibility with old backups.
 */
public class SavedIncBackupV0 implements SavedIncrementalBackup {

    private final ObjectCollection2 objectCollection2;
    private final String backupName;
    private final LocalDateTime namedBackupTime;

    public SavedIncBackupV0(ObjectCollection2 objectCollection2, BackupFileNameEncoder.BackupBasicInformation backupBasicInformation) {
        Objects.requireNonNull(objectCollection2);
        Objects.requireNonNull(backupBasicInformation);

        this.objectCollection2 = objectCollection2;
        this.backupName = backupBasicInformation.customName;
        this.namedBackupTime = backupBasicInformation.time;
    }


    @Override
    public ObjectCollection2 getObjectCollection() {
        return objectCollection2;
    }

    @Override
    public String getBackupName() {
        return backupName;
    }

    @Override
    public ZonedDateTime getBackupTime() {
        return namedBackupTime.atZone(ZoneId.systemDefault());
    }

    @Override
    public int getFilesAdded() {
        return -1; // missing info
    }

    @Override
    public long getTotalSizeBytes() {
        return -1; // missing info
    }

    @Override
    public long getIncreasedSizeBytes() {
        return -1; // missing info
    }

    @Override
    public String toString() {
        return String.format("(Legacy Backup) %s, created at %s", backupName, namedBackupTime);
    }
}