-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathResult.java
More file actions
85 lines (66 loc) · 2.18 KB
/
Copy pathResult.java
File metadata and controls
85 lines (66 loc) · 2.18 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
/*
* Copyright 2016-2025 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 dev.learning.xapi.model.validation.constraints.VaildScore;
import dev.learning.xapi.model.validation.constraints.ValidDuration;
import jakarta.validation.Valid;
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 @VaildScore 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. */
@ValidDuration 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 var 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;
}
}
}