-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathPerson.java
More file actions
114 lines (93 loc) · 2.41 KB
/
Person.java
File metadata and controls
114 lines (93 loc) · 2.41 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
111
112
113
114
/*
* Copyright 2016-2023 Berry Cloud Ltd. All rights reserved.
*/
package dev.learning.xapi.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import dev.learning.xapi.model.validation.constraints.Mbox;
import jakarta.validation.Valid;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import lombok.Builder;
import lombok.Builder.Default;
import lombok.Value;
/**
* This class represents the xAPI Person object.
*
* @author Thomas Turrell-Croft
*
* @see <a href=
* "https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Communication.md#person-properties">xAPI
* Person</a>
*/
@Value
@Builder
@JsonInclude(Include.NON_EMPTY)
@JsonIgnoreProperties(value = {"firstName", "lastName"})
public class Person {
@Default
private final ObjectType objectType = ObjectType.PERSON;
/**
* List of names.
*/
private List<String> name;
/**
* List of e-mail addresses.
*/
private List<@Mbox String> mbox;
/**
* List of the SHA1 hashes of mailto IRIs.
*/
@JsonProperty("mbox_sha1sum")
private List<String> mboxSha1sum;
/**
* List of openids that uniquely identify the Agents retrieved.
*/
private List<URI> openid;
/**
* List of accounts.
*/
@Valid
private List<Account> account;
// **Warning** do not add fields that are not required by the xAPI specification.
/**
* Builder for Person.
*/
public static class Builder {
// This static class extends the lombok builder.
/**
* Consumer Builder for account.
*
* @param account The Consumer Builder for account.
*
* @return This builder
*
* @see Person#account
*/
public Builder addAccount(Consumer<Account.Builder> account) {
final Account.Builder builder = Account.builder();
account.accept(builder);
return addAccount(builder.build());
}
/**
* Adds an account entry.
*
* @param account The account to add.
*
* @return This builder
*
* @see Person#account
*/
public Builder addAccount(Account account) {
if (this.account == null) {
this.account = new ArrayList<Account>();
}
this.account.add(account);
return this;
}
}
}