View Javadoc
1   package fr.tiogars.chat.client;
2   
3   import java.time.Instant;
4   
5   /**
6    * Represents a Task returned by the Task API.
7    *
8    * @param id persistent identifier
9    * @param code unique template code
10   * @param label display label
11   * @param description optional description
12   * @param createdDate creation timestamp
13   * @param lastModifiedDate last modification timestamp
14   * @param createdBy username at creation
15   * @param lastModifiedBy username at the last modification
16   * @since 0.1.0
17   */
18  public record Task(
19          Long id,
20          String code,
21          String label,
22          String description,
23          Instant createdDate,
24          Instant lastModifiedDate,
25          String createdBy,
26          String lastModifiedBy,
27          TaskStatus status,
28          TaskPriority priority,
29          java.time.LocalDate dueDate,
30          String assignedTo,
31          java.util.List<Long> tagIds,
32          Long nomenclatureId
33  ) {
34      public Task {
35          status = status == null ? TaskStatus.TODO : status;
36          priority = priority == null ? TaskPriority.NORMAL : priority;
37          tagIds = tagIds == null ? java.util.List.of() : java.util.List.copyOf(tagIds);
38      }
39  
40      public Task(Long id, String code, String label, String description,
41              Instant createdDate, Instant lastModifiedDate, String createdBy, String lastModifiedBy) {
42          this(id, code, label, description, createdDate, lastModifiedDate, createdBy, lastModifiedBy,
43                  TaskStatus.TODO, TaskPriority.NORMAL, null, null, java.util.List.of(), null);
44      }
45      /**
46       * Creates a template without audit actors for compatibility with older API responses.
47       *
48       * @param id persistent identifier
49       * @param code unique template code
50       * @param label display label
51       * @param description optional description
52       * @param createdDate creation timestamp
53       * @param lastModifiedDate last modification timestamp
54       */
55      public Task(Long id, String code, String label, String description,
56              Instant createdDate, Instant lastModifiedDate) {
57          this(id, code, label, description, createdDate, lastModifiedDate, null, null);
58      }
59  }