java大神有吗?compareTo return 失效 通过判断是否在map内条件下的return debug后发现似乎被忽略了,跑不到那里。

桃哥543 2018-05-14 04:40:08
java大神有吗?前4个return 似乎被编译器忽略了?继承的Comparable;

@Override
public int compareTo(Conversation another) {
if (another instanceof Conversation) {
Conversation anotherConversation = (Conversation) another;
if (type == TIMConversationType.Group) {
if (ImSettingManager.getTopContactMap().containsKey(BeanContactSetting.FONT_WORD_TYPE_GROUP +
getIdentify())) {
if (anotherConversation.type == TIMConversationType.Group) {
if (ImSettingManager.getTopContactMap().containsKey(BeanContactSetting.FONT_WORD_TYPE_GROUP +
anotherConversation.getIdentify()))
return 0;
else
return 1;
}else{
if (ImSettingManager.getTopContactMap().containsKey(BeanContactSetting.FONT_WORD_TYPE_PEOPLE +
anotherConversation.getIdentify()))
return 0;
else
return 1;
}
}
} else {
if (anotherConversation.type == TIMConversationType.Group) {
if (ImSettingManager.getTopContactMap().containsKey(BeanContactSetting.FONT_WORD_TYPE_GROUP +
anotherConversation.getIdentify()))
return 0;
else
return 1;
}else{
if (ImSettingManager.getTopContactMap().containsKey(BeanContactSetting.FONT_WORD_TYPE_PEOPLE +
anotherConversation.getIdentify()))
return 0;
else
return 1;
}
}
long timeGap = anotherConversation.getLastMessageTime() - getLastMessageTime();
if (timeGap > 0) return 1;
else if (timeGap < 0) return -1;
return 0;
} else {
throw new ClassCastException();
}
...全文
1036 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
范特西97 2018-05-14
  • 打赏
  • 举报
回复
你的第一个if进入了吗,是不是传入的类型不是instanceof的子类或者没有实现接口
桃哥543 2018-05-14
  • 打赏
  • 举报
回复
进入了, 传的类型就是那个类。

50,639

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧