为了账号安全,请及时绑定邮箱和手机立即绑定

Jackson 可以在 (de)/序列化期间使用具有包含在 java.util.Map

Jackson 可以在 (de)/序列化期间使用具有包含在 java.util.Map

胡说叔叔 2021-08-25 16:25:59
这是我的初始设置String json = "{'text': 'what is my balance', 'mid': 'D1dexnEBTCefEdRWveEt8A', 'seq': 73}";import java.io.Serializable;import java.time.LocalDateTime;import org.apache.commons.lang3.builder.EqualsBuilder;import com.fasterxml.jackson.annotation.JsonProperty;import com.fasterxml.jackson.databind.annotation.JsonDeserialize;@JsonDeserialize(builder = Messages.MessageBuilder.class)public class Message implements Serializable {  @JsonProperty("id")  public final String id;  @JsonProperty("botId")  public final String botId;  @JsonProperty("userId")  public final String userId;  public final String userIdKey;  public boolean echoText=false;  public String text;  public String timeZone;  public volatile String username;  @JsonProperty("conversationId")  public volatile String conversationId;  public volatile int kaiUserId;  public volatile String token;  public final LocalDateTime inboundReceivedAt;  public volatile LocalDateTime outboundSentAt;  final String key;  private final int _hashCode;  public volatile long lastAccess = System.currentTimeMillis();  public Message(final String pMessageId, final String pUserId, final String pBotId, final String pConversationId, final String pText) {    id = pMessageId;    userId = pUserId;    botId = pBotId;    conversationId = pConversationId;    text = pText;    inboundReceivedAt = LocalDateTime.now();    key = id + "-" + userId + "-" + botId;    userIdKey = userId + "~" + botId;    _hashCode = key.hashCode();  }  void touch() { lastAccess = System.currentTimeMillis(); }  @Override public int hashCode() { return _hashCode; }  @Override public boolean equals(final Object pObject) {    if (!(pObject instanceof Message)) { return false; }    return new EqualsBuilder().append(id, ((Message)pObject).id)                              .append(botId, ((Message)pObject).botId)                              .append(userId, ((Message)pObject).userId)                              .isEquals();  }
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 134 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信