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.History;
29 import de.kaiserpfalzedv.commons.api.resources.TimeStampPattern;
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 example = TimeStampPattern.VALID_EXAMPLE,
68 pattern = TimeStampPattern.VALID_PATTERN,
69 minLength = TimeStampPattern.VALID_LENGTH,
70 maxLength = TimeStampPattern.VALID_LENGTH
71 )
72 @Builder.Default
73 @Pattern(regexp = TimeStampPattern.VALID_PATTERN, message = TimeStampPattern.VALID_PATTERN_MSG)
74 private final OffsetDateTime timeStamp = OffsetDateTime.now(ZoneOffset.UTC);
75
76 @Schema(
77 name = "Status",
78 description = "The resource status after the change.",
79 required = true,
80 defaultValue = "not-specified",
81 example = HasName.VALID_NAME_EXAMPLE,
82 pattern = HasName.VALID_NAME_PATTERN,
83 minLength = HasName.VALID_NAME_MIN_LENGTH,
84 maxLength = HasName.VALID_NAME_MAX_LENGTH
85 )
86 @Builder.Default
87 @Size(min = HasName.VALID_NAME_MIN_LENGTH, max = HasName.VALID_NAME_MAX_LENGTH, message = HasName.VALID_NAME_LENGTH_MSG)
88 @Pattern(regexp = HasName.VALID_NAME_PATTERN, message = HasName.VALID_NAME_PATTERN_MSG)
89 private final String status = "not-specified";
90
91 @Schema(
92 name = "Message",
93 description = "The human readable description of the change.",
94 nullable = true
95 )
96 @Builder.Default
97 private final String message = null;
98
99
100 @SuppressWarnings("MethodDoesntCallSuperMethod")
101 @Override
102 @SuppressFBWarnings(value = "CN_IDIOM_NO_SUPER_CALL", justification = "Using the lombok builder.")
103 public History clone() {
104 return this.toBuilder().build();
105 }
106 }