com.hn.im.easemob.comm.body.ChatRoomBody Maven / Gradle / Ivy
package com.hn.im.easemob.comm.body;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ContainerNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.hn.im.easemob.comm.wrapper.BodyWrapper;
import cn.hutool.core.util.StrUtil;
public class ChatRoomBody implements BodyWrapper {
private String name;
private String desc;
private Long maxUsers;
private String owner;
private String[] members;
public ChatRoomBody(String name, String desc, Long maxUsers, String owner, String[] members) {
this.name = name;
this.desc = desc;
this.maxUsers = maxUsers;
this.owner = owner;
this.members = members;
}
public String getName() {
return name;
}
public String getDesc() {
return desc;
}
public Long getMaxUsers() {
return maxUsers;
}
public String getOwner() {
return owner;
}
public String[] getMembers() {
return members;
}
public ContainerNode> getBody() {
ObjectNode body = JsonNodeFactory.instance.objectNode();
body.put("name", name).put("description", desc).put("owner", owner);
if (null != maxUsers) {
body.put("maxusers", maxUsers);
}
if (members != null && members.length > 0) {
ArrayNode membersNode = body.putArray("members");
for (String member : members) {
membersNode.add(member);
}
}
return body;
}
public Boolean validate() {
return StrUtil.isNotBlank(name) && StrUtil.isNotBlank(desc) && StrUtil.isNotBlank(owner);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy