标签:分析 key值 数据结构 项目 技术分享 ring 标签 app 底层实现
/** * 新车上市相关DTO * Created by WangMeng on 2017/8/9. */ public class NewListedCarDTO { /** * id */ private long id; /** * 车系id */ private long seriesId; /** * 头条文章id */ private long teleId; /** * 车系显示名称 */ private String seriesTitle; /** * 车系标签 */ private String seriesTag; /** * 上市时间 */ private String listTime; /** * 上市状态 * 0:不可用 1:即将上市 2:已经上市 */ private int articleType; private int listYear; private int listMonth; @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof NewListedCarDTO)) return false; NewListedCarDTO that = (NewListedCarDTO) o; if (seriesId != that.seriesId) return false; if (listYear != that.listYear) return false; return listMonth == that.listMonth; } @Override public int hashCode() { int result = (int) (seriesId ^ (seriesId >>> 32)); result = 31 * result + listYear; result = 31 * result + listMonth; return result; } public long getId() { return id; } public void setId(long id) { this.id = id; } public long getSeriesId() { return seriesId; } public void setSeriesId(long seriesId) { this.seriesId = seriesId; } public long getTeleId() { return teleId; } public void setTeleId(long teleId) { this.teleId = teleId; } public String getSeriesTitle() { return seriesTitle; } public void setSeriesTitle(String seriesTitle) { this.seriesTitle = seriesTitle; } public String getSeriesTag() { return seriesTag; } public void setSeriesTag(String seriesTag) { this.seriesTag = seriesTag; } public String getListTime() { return listTime; } public void setListTime(String listTime) { this.listTime = listTime; } public int getArticleType() { return articleType; } public void setArticleType(int articleType) { this.articleType = articleType; } public int getListYear() { return listYear; } public void setListYear(int listYear) { this.listYear = listYear; } public int getListMonth() { return listMonth; } public void setListMonth(int listMonth) { this.listMonth = listMonth; } }
这里要根据seriesId和listMonth这两个字段去重, 所以必须重写equals和hashCode方法。
标签:分析 key值 数据结构 项目 技术分享 ring 标签 app 底层实现
原文地址:http://www.cnblogs.com/wang-meng/p/7501433.html