55 lines
1.9 KiB
Kotlin
55 lines
1.9 KiB
Kotlin
package com.sw.dualscreen.objbox
|
|
|
|
import com.sw.dualscreen.utils.DateTimeUtil
|
|
import io.objectbox.annotation.Entity
|
|
import io.objectbox.annotation.HnswIndex
|
|
import io.objectbox.annotation.Id
|
|
import io.objectbox.annotation.VectorDistanceType
|
|
import java.time.LocalDateTime
|
|
|
|
@Entity
|
|
data class Food(
|
|
@Id var id: Long = 0,
|
|
var collectId: String? = null,
|
|
var foodId: String? = null,
|
|
var foodName: String? = null,
|
|
var version: String? = null,
|
|
var createTime: String = DateTimeUtil.formatDateTime(LocalDateTime.now()),
|
|
var isDel: Boolean = false,
|
|
var otherField: String? = null,
|
|
@HnswIndex(dimensions = 512, distanceType = VectorDistanceType.DOT_PRODUCT)
|
|
var foodVector: FloatArray? = null
|
|
) {
|
|
override fun equals(other: Any?): Boolean {
|
|
if (this === other) return true
|
|
if (javaClass != other?.javaClass) return false
|
|
|
|
other as Food
|
|
|
|
if (id != other.id) return false
|
|
if (isDel != other.isDel) return false
|
|
if (collectId != other.collectId) return false
|
|
if (foodId != other.foodId) return false
|
|
if (foodName != other.foodName) return false
|
|
if (version != other.version) return false
|
|
if (createTime != other.createTime) return false
|
|
if (otherField != other.otherField) return false
|
|
if (!foodVector.contentEquals(other.foodVector)) return false
|
|
|
|
return true
|
|
}
|
|
|
|
override fun hashCode(): Int {
|
|
var result = id.hashCode()
|
|
result = 31 * result + isDel.hashCode()
|
|
result = 31 * result + (collectId?.hashCode() ?: 0)
|
|
result = 31 * result + (foodId?.hashCode() ?: 0)
|
|
result = 31 * result + (foodName?.hashCode() ?: 0)
|
|
result = 31 * result + (version?.hashCode() ?: 0)
|
|
result = 31 * result + createTime.hashCode()
|
|
result = 31 * result + (otherField?.hashCode() ?: 0)
|
|
result = 31 * result + (foodVector?.contentHashCode() ?: 0)
|
|
return result
|
|
}
|
|
|
|
} |