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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
package com.keuin.kbackupfabric.backup.incremental.serializer;
import com.keuin.kbackupfabric.backup.BackupFilesystemUtil;
import com.keuin.kbackupfabric.backup.incremental.ObjectCollection2;
import com.keuin.kbackupfabric.util.DateUtil;
import java.io.Serializable;
import java.time.ZonedDateTime;
import java.util.Objects;
public class SavedIncBackupV1 implements SavedIncrementalBackup, Serializable {
private final ObjectCollection2 objectCollection2;
private final String backupName;
private final ZonedDateTime backupTime;
private final long totalSizeBytes;
private final long increasedSizeBytes;
private final int filesAdded;
private final int totalFiles;
public SavedIncBackupV1(ObjectCollection2 objectCollection2, String backupName, ZonedDateTime backupTime, long totalSizeBytes, long increasedSizeBytes, int filesAdded, int totalFiles) {
this.totalFiles = totalFiles;
Objects.requireNonNull(objectCollection2);
Objects.requireNonNull(backupName);
Objects.requireNonNull(backupTime);
this.objectCollection2 = objectCollection2;
this.backupName = backupName;
this.backupTime = backupTime;
this.totalSizeBytes = totalSizeBytes;
this.increasedSizeBytes = increasedSizeBytes;
this.filesAdded = filesAdded;
}
@Override
public ObjectCollection2 getObjectCollection() {
return objectCollection2;
}
@Override
public String getBackupName() {
return backupName;
}
@Override
public ZonedDateTime getBackupTime() {
return backupTime;
}
@Override
public int getFilesAdded() {
return filesAdded;
}
@Override
public long getTotalSizeBytes() {
return totalSizeBytes;
}
@Override
public long getIncreasedSizeBytes() {
return increasedSizeBytes;
}
public int getTotalFiles() {
return totalFiles;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SavedIncBackupV1 that = (SavedIncBackupV1) o;
return totalSizeBytes == that.totalSizeBytes &&
increasedSizeBytes == that.increasedSizeBytes &&
filesAdded == that.filesAdded &&
totalFiles == that.totalFiles &&
objectCollection2.equals(that.objectCollection2) &&
backupName.equals(that.backupName) &&
backupTime.equals(that.backupTime);
}
@Override
public int hashCode() {
return Objects.hash(objectCollection2, backupName, backupTime, totalSizeBytes, increasedSizeBytes, filesAdded, totalFiles);
}
@Override
public String toString() {
return String.format(
"%s, created at %s, files: %d (total size: %s), copied size: %s, files added: %d",
backupName,
DateUtil.getString(backupTime),
totalFiles,
BackupFilesystemUtil.getFriendlyFileSizeString(totalSizeBytes),
BackupFilesystemUtil.getFriendlyFileSizeString(increasedSizeBytes),
filesAdded
);
}
}
|