-class JsonGroupInfo {
-
- @JsonProperty
- final String groupId;
-
- @JsonProperty
- final String type;
-
- @JsonProperty
- @JsonInclude(JsonInclude.Include.NON_NULL)
- final String name;
-
- @JsonProperty
- @JsonInclude(JsonInclude.Include.NON_NULL)
- final List<String> members;
-
- JsonGroupInfo(SignalServiceGroup groupInfo) {
- this.groupId = Base64.getEncoder().encodeToString(groupInfo.getGroupId());
- this.type = groupInfo.getType().toString();
- this.name = groupInfo.getName().orNull();
- if (groupInfo.getMembers().isPresent()) {
- this.members = groupInfo.getMembers()
- .get()
- .stream()
- .map(Util::getLegacyIdentifier)
- .collect(Collectors.toList());
- } else {
- this.members = null;
- }
+record JsonGroupInfo(
+ String groupId,
+ String type,
+ @JsonInclude(JsonInclude.Include.NON_NULL) String name,
+ @JsonInclude(JsonInclude.Include.NON_NULL) List<String> members
+) {
+
+ static JsonGroupInfo from(SignalServiceGroup groupInfo) {
+ return new JsonGroupInfo(Base64.getEncoder().encodeToString(groupInfo.getGroupId()),
+ groupInfo.getType().toString(),
+ groupInfo.getName().orNull(),
+ groupInfo.getMembers().isPresent() ? groupInfo.getMembers()
+ .get()
+ .stream()
+ .map(Util::getLegacyIdentifier)
+ .collect(Collectors.toList()) : null);