1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package de.kaiserpfalzedv.commons.core.resources;
19
20 import java.time.OffsetDateTime;
21 import java.time.ZoneOffset;
22
23 import org.eclipse.microprofile.openapi.annotations.media.Schema;
24
25 import com.fasterxml.jackson.annotation.JsonInclude;
26
27 import de.kaiserpfalzedv.commons.api.resources.HasName;
28 import de.kaiserpfalzedv.commons.api.resources.HasTimestamps;
29 import de.kaiserpfalzedv.commons.api.resources.History;
30 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
31 import jakarta.validation.constraints.Pattern;
32 import jakarta.validation.constraints.Size;
33 import lombok.AllArgsConstructor;
34 import lombok.Builder;
35 import lombok.Getter;
36 import lombok.NoArgsConstructor;
37 import lombok.ToString;
38 import lombok.extern.jackson.Jacksonized;
39
40
41
42
43
44
45
46
47 @Jacksonized
48 @Builder(toBuilder = true)
49 @AllArgsConstructor
50 @NoArgsConstructor
51 @Getter
52 @ToString
53 @JsonInclude(JsonInclude.Include.NON_ABSENT)
54 @Schema(
55 name = "History",
56 description = "A single history entry of a change."
57 )
58 public class HistoryImpl implements History {
59
60 private static final long serialVersionUID = 0L;
61
62 @Schema(
63 name = "TimeStamp",
64 description = "The timestamp of the change.",
65 required = true,
66 defaultValue = "now",
67 pattern = HasTimestamps.VALID_PATTERN,
68 minLength = HasTimestamps.VALID_LENGTH,
69 maxLength = HasTimestamps.VALID_LENGTH
70 )
71 @Builder.Default
72 @Pattern(regexp = HasTimestamps.VALID_PATTERN, message = HasTimestamps.VALID_PATTERN_MSG)
73 private final OffsetDateTime timeStamp = OffsetDateTime.now(ZoneOffset.UTC);
74
75 @Schema(
76 name = "Status",
77 description = "The resource status after the change.",
78 required = true,
79 defaultValue = "not-specified",
80 pattern = HasName.VALID_NAME_PATTERN,
81 minLength = HasName.VALID_NAME_MIN_LENGTH,
82 maxLength = HasName.VALID_NAME_MAX_LENGTH
83 )
84 @Builder.Default
85 @Size(min = HasName.VALID_NAME_MIN_LENGTH, max = HasName.VALID_NAME_MAX_LENGTH, message = HasName.VALID_NAME_LENGTH_MSG)
86 @Pattern(regexp = HasName.VALID_NAME_PATTERN, message = HasName.VALID_NAME_PATTERN_MSG)
87 private final String status = "not-specified";
88
89 @Schema(
90 name = "Message",
91 description = "The human readable description of the change.",
92 nullable = true
93 )
94 @Builder.Default
95 private final String message = null;
96
97
98 @SuppressWarnings({"MethodDoesntCallSuperMethod","java:S1182","java:S2975"})
99 @Override
100 @SuppressFBWarnings(value = "CN_IDIOM_NO_SUPER_CALL", justification = "Using the lombok builder.")
101 public History clone() {
102 return this.toBuilder().build();
103 }
104 }