1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package de.kaiserpfalzedv.rpg.core.dice.mat;
19
20 import com.fasterxml.jackson.annotation.JsonInclude;
21 import lombok.*;
22 import lombok.extern.jackson.Jacksonized;
23 import org.eclipse.microprofile.openapi.annotations.media.Schema;
24
25 import java.io.Serializable;
26 import java.util.ArrayList;
27 import java.util.List;
28 import java.util.Optional;
29 import java.util.StringJoiner;
30
31
32
33
34
35
36
37 @Jacksonized
38 @Builder(toBuilder = true)
39 @AllArgsConstructor
40 @NoArgsConstructor
41 @Getter
42 @ToString
43 @EqualsAndHashCode
44 @JsonInclude(JsonInclude.Include.NON_ABSENT)
45 @Schema(name = "RollTotal", description = "A generic result of a die roll.")
46 public class RollTotal implements Serializable {
47 @Builder.Default
48 private final List<ExpressionTotal> expressions = new ArrayList<>();
49
50 @Builder.Default
51 private final Optional<String> comment = Optional.empty();
52
53 public String getDescription() {
54 StringJoiner result = new StringJoiner(" - ");
55
56 for (ExpressionTotal r : getExpressions()) {
57 result.add(r.getDescription());
58 }
59
60 return result.toString();
61 }
62
63
64
65
66
67
68 public boolean isEmpty() {
69 return getExpressions().size() == 0;
70 }
71 }