1 /*
2 * Copyright (c) 2023. Roland T. Lichti, Kaiserpfalz EDV-Service.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18 package de.kaiserpfalzedv.commons.api.resources;
19
20 import java.io.Serializable;
21 import java.util.List;
22
23 import org.eclipse.microprofile.openapi.annotations.media.Schema;
24
25 import jakarta.validation.constraints.Max;
26 import jakarta.validation.constraints.Min;
27 import jakarta.validation.constraints.Size;
28
29 /**
30 * <p>Status -- .</p>
31 *
32 * @author rlichti {@literal <rlichti@kaiserpfalz-edv.de>}
33 * @since 1.0.0 2023-01-19
34 */
35 public interface Status extends Serializable, Cloneable {
36 /**
37 * Adds a new history entry.
38 *
39 * @param status The status of this entry.
40 * @param message The generic message for this history entry.
41 * @return TRUE if the history could be added.
42 */
43 Status addHistory(String status, String message);
44
45 @Schema(
46 name = "observedGeneration",
47 description = "The generation of this resource which is observed.",
48 required = true,
49 defaultValue = "0",
50 minimum = "0",
51 maxItems = Integer.MAX_VALUE
52 )
53 @Min(value = 0, message = "The generation must be at least 0.")
54 @Max(value = Integer.MAX_VALUE, message = "The generation must not be bigger than " + Integer.MAX_VALUE + ".")
55 Integer getObservedGeneration();
56
57 @Schema(
58 name = "history",
59 description = "A list of changes of the resource status.",
60 nullable = true,
61 minItems = 0
62 )
63 @Size
64 <T extends History> List<T> getHistory();
65 }