fix(food): 修复Food类的equals和hashCode方法
- 在equals方法中添加version字段比较 - 在hashCode方法中添加version字段哈希计算 - 确保对象比较的一致性
This commit is contained in:
@@ -24,6 +24,7 @@ data class Food(
|
||||
if (foodIdx != other.foodIdx) return false
|
||||
if (name != other.name) return false
|
||||
if (!foodVector.contentEquals(other.foodVector)) return false
|
||||
if (version != other.version) return false
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -33,6 +34,8 @@ data class Food(
|
||||
result = 31 * result + foodIdx
|
||||
result = 31 * result + (name?.hashCode() ?: 0)
|
||||
result = 31 * result + (foodVector?.contentHashCode() ?: 0)
|
||||
result = 31 * result + (version?.hashCode() ?: 0)
|
||||
return result
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user