|
@@ -37,13 +37,14 @@ import java.util.Optional;
|
37
|
37
|
public class UserInfoResponseEvent extends ServerDisplayableEvent {
|
38
|
38
|
|
39
|
39
|
private final User user;
|
40
|
|
- private final Map<UserInfoEvent.UserInfoType, String> info;
|
|
40
|
+ private final Map<UserInfoEvent.UserInfoType, UserInfoProperty> info;
|
41
|
41
|
|
42
|
42
|
public UserInfoResponseEvent(final Connection connection, final long date,
|
43
|
43
|
final User user, final Map<UserInfoEvent.UserInfoType, String> info) {
|
44
|
44
|
super(date, connection);
|
45
|
45
|
this.user = user;
|
46
|
|
- this.info = new EnumMap<>(info);
|
|
46
|
+ this.info = new EnumMap<>(UserInfoEvent.UserInfoType.class);
|
|
47
|
+ info.forEach((key, value) -> this.info.put(key, new UserInfoProperty(key, value)));
|
47
|
48
|
}
|
48
|
49
|
|
49
|
50
|
/**
|
|
@@ -63,16 +64,40 @@ public class UserInfoResponseEvent extends ServerDisplayableEvent {
|
63
|
64
|
* @return An optional containing the information, if it was provided.
|
64
|
65
|
*/
|
65
|
66
|
public Optional<String> getInfo(final UserInfoEvent.UserInfoType type) {
|
66
|
|
- return Optional.ofNullable(info.get(type));
|
|
67
|
+ return Optional.ofNullable(info.get(type)).map(UserInfoProperty::getRawValue);
|
67
|
68
|
}
|
68
|
69
|
|
69
|
70
|
/**
|
70
|
|
- * Gets a collection of all info entries in the response.
|
|
71
|
+ * Gets a collection of all info properties in the response.
|
71
|
72
|
*
|
72
|
|
- * @return A collection of all user info entries.
|
|
73
|
+ * @return A collection of all user info properties.
|
73
|
74
|
*/
|
74
|
|
- public Collection<Map.Entry<UserInfoEvent.UserInfoType, String>> getEntries() {
|
75
|
|
- return info.entrySet();
|
|
75
|
+ public Collection<UserInfoProperty> getProperties() {
|
|
76
|
+ return info.values();
|
|
77
|
+ }
|
|
78
|
+
|
|
79
|
+ public static class UserInfoProperty {
|
|
80
|
+
|
|
81
|
+ private final UserInfoEvent.UserInfoType type;
|
|
82
|
+ private final String rawValue;
|
|
83
|
+
|
|
84
|
+ public UserInfoProperty(final UserInfoEvent.UserInfoType type, final String rawValue) {
|
|
85
|
+ this.type = type;
|
|
86
|
+ this.rawValue = rawValue;
|
|
87
|
+ }
|
|
88
|
+
|
|
89
|
+ public UserInfoEvent.UserInfoType getType() {
|
|
90
|
+ return type;
|
|
91
|
+ }
|
|
92
|
+
|
|
93
|
+ public String getRawValue() {
|
|
94
|
+ return rawValue;
|
|
95
|
+ }
|
|
96
|
+
|
|
97
|
+ public String getFriendlyName() {
|
|
98
|
+ return type.name().charAt(0) + type.name().substring(1).toLowerCase().replace('_', ' ');
|
|
99
|
+ }
|
|
100
|
+
|
76
|
101
|
}
|
77
|
102
|
|
78
|
103
|
}
|