-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathResult.java
More file actions
110 lines (88 loc) · 2.47 KB
/
Result.java
File metadata and controls
110 lines (88 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* Copyright 2016-2023 Berry Cloud Ltd. All rights reserved.
*/
package dev.learning.xapi.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import dev.learning.xapi.model.validation.constraints.HasScheme;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Pattern;
import java.net.URI;
import java.util.LinkedHashMap;
import java.util.function.Consumer;
import lombok.Builder;
import lombok.Value;
/**
* This class represents the xAPI Result object.
*
* @author Thomas Turrell-Croft
*
* @see <a href="https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#result">xAPI
* Result</a>
*/
@Value
@Builder
@JsonInclude(Include.NON_EMPTY)
public class Result {
/**
* The score of the Agent in relation to the success or quality of the experience.
*/
@Valid
private Score score;
/**
* Indicates whether or not the attempt on the Activity was successful.
*/
private Boolean success;
/**
* Indicates whether or not the Activity was completed.
*/
private Boolean completion;
/**
* A response appropriately formatted for the given Activity.
*/
private String response;
/**
* Period of time over which the Statement occurred.
*/
// Java Duration does not store ISO 8601:2004 durations.
@Pattern(regexp = "^(P\\d+W)?$|^P(?!$)(\\d+Y)?(\\d+M)?" // NOSONAR
+ "(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d*\\.?\\d+S)?)?$", // NOSONAR
flags = Pattern.Flag.CASE_INSENSITIVE,
message = "Must be a valid ISO 8601:2004 duration format.")
private String duration;
private LinkedHashMap<@HasScheme URI, Object> extensions;
// **Warning** do not add fields that are not required by the xAPI specification.
/**
* Builder for Result.
*/
public static class Builder {
// This static class extends the lombok builder.
/**
* Consumer Builder for score.
*
* @param score The Consumer Builder for score.
*
* @return This builder
*
* @see Result#score
*/
public Builder score(Consumer<Score.Builder> score) {
final Score.Builder builder = Score.builder();
score.accept(builder);
return score(builder.build());
}
/**
* Sets the score.
*
* @param score The score of the Result.
*
* @return This builder
*
* @see Result#score
*/
public Builder score(Score score) {
this.score = score;
return this;
}
}
}