1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package de.kaiserpfalzedv.commons.api.resources;
19
20 import java.time.OffsetDateTime;
21
22 import org.eclipse.microprofile.openapi.annotations.media.Schema;
23
24 import jakarta.validation.constraints.NotNull;
25
26
27
28
29
30
31
32
33 public interface HasTimestamps {
34 String VALID_PATTERN = "^[0-9]{4}(-[0-9]{2}){2}T([0-9]{2}:){2}[0-9]{2}.[0-9]{6}+[0-9]{2}:[0-9]{2}$";
35 String VALID_PATTERN_MSG = "The timestamp must match the pattern '" + VALID_PATTERN + "'";
36 int VALID_LENGTH = 32;
37 String VALID_LENGTH_MSG = "The timestamp must be exactly 32 characters long.";
38 String VALID_EXAMPLE = "2022-01-04T21:51:00.000000+01:00";
39
40 @Schema(
41 name = "created",
42 description = "The creation date of this resource.",
43 maxLength = HasTimestamps.VALID_LENGTH,
44 pattern = HasTimestamps.VALID_PATTERN
45 )
46 @NotNull
47 OffsetDateTime getCreated();
48
49 @Schema(
50 name = "modified",
51 description = "The modified date of this resource.",
52 maxLength = HasTimestamps.VALID_LENGTH,
53 pattern = HasTimestamps.VALID_PATTERN
54 )
55 @NotNull
56 OffsetDateTime getModified();
57
58 @Schema(
59 name = "deleted",
60 description = "The deletion date of this resource.",
61 maxLength = HasTimestamps.VALID_LENGTH,
62 pattern = HasTimestamps.VALID_PATTERN
63 )
64 @NotNull
65 OffsetDateTime getDeleted();
66 }