Skip to content

Package: Backup

Backup

nameinstructionbranchcomplexitylinemethod
getBackupFiles()
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * *********************************************************************************************************************
3: *
4: * SolidBlue 3: Data safety
5: * http://tidalwave.it/projects/solidblue3
6: *
7: * Copyright (C) 2023 - 2023 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *********************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/solidblue3j-src
23: * git clone https://github.com/tidalwave-it/solidblue3j-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.datamanager.model;
28:
29: import jakarta.annotation.Nonnull;
30: import java.time.LocalDateTime;
31: import java.util.List;
32: import java.util.Optional;
33: import java.util.function.Supplier;
34: import java.nio.file.Path;
35: import it.tidalwave.util.As;
36: import it.tidalwave.util.Id;
37: import it.tidalwave.util.LazySupplier;
38: import lombok.Builder;
39: import lombok.EqualsAndHashCode;
40: import lombok.Getter;
41: import lombok.ToString;
42: import lombok.experimental.Delegate;
43: import lombok.experimental.Tolerate;
44:
45: /***********************************************************************************************************************
46: *
47: * A backup.
48: *
49: * @stereotype Model
50: * @author Fabrizio Giudici
51: *
52: **********************************************************************************************************************/
53: @Builder @EqualsAndHashCode @ToString(doNotUseGetters = true)
54: public final class Backup implements As
55: {
56: public static class BackupBuilder
57: {
58: @Nonnull @Tolerate
59: public BackupBuilder latestCheckDate (@Nonnull final LocalDateTime timestamp)
60: {
61: return latestCheckDate(Optional.of(timestamp));
62: }
63:
64: @Nonnull @Tolerate
65: public BackupBuilder backupFiles (@Nonnull final Supplier<List<BackupFile>> backupFiles)
66: {
67: return backupFiles(LazySupplier.of(backupFiles));
68: }
69: }
70:
71: @Delegate @ToString.Exclude @EqualsAndHashCode.Exclude
72: private final As asDelegate = As.forObject(this);
73:
74: @Getter @Nonnull
75: private final Id id;
76:
77: /** The label of the backup. */
78: @Getter @Nonnull
79: private final String label;
80:
81: /** The volume id of the backup. */
82: @Getter @Nonnull
83: private final Id volumeId;
84:
85: /** Whether the backup is encrypted. */
86: @Getter
87: private final boolean encrypted;
88:
89: /** The base path of the files in the backup. */
90: @Getter @Nonnull
91: private final Path basePath;
92:
93: /** The timestamp of backup creation. */
94: @Getter @Nonnull
95: private final LocalDateTime creationDate;
96:
97: /** The timestamp of backup registration. */
98: @Getter @Nonnull
99: private final LocalDateTime registrationDate;
100:
101: /** The latest time the backup was checked. */
102: @Getter @Nonnull
103: private final Optional<LocalDateTime> latestCheckDate;
104:
105: @Nonnull
106: private final LazySupplier<List<BackupFile>> backupFiles;
107:
108: @Nonnull
109: public List<BackupFile> getBackupFiles()
110: {
111: return backupFiles.get();
112: }
113: }