package com.example.myapplication.database.room.model.user

import androidx.room.ColumnInfo
import androidx.room.Entity
import java.util.Objects.hash

@Entity(
    tableName = "users_items",
    primaryKeys = ["user_id", "item_id"]
)
data class UserItemCrossRef(
    @ColumnInfo(name = "user_id", index = true)
    val userId: Int,
    @ColumnInfo(name = "item_id", index = true)
    val itemId: Int,
    @ColumnInfo(name = "count")
    val count: Int,
) {
    override fun equals(other: Any?): Boolean {
        if (this === other) {
            return true
        }
        if (javaClass != other?.javaClass) {
            return false
        }
        other as UserItemCrossRef
        if (userId == other.userId && itemId == other.itemId) {
            return true
        }
        return false
    }

    override fun hashCode(): Int {
        return hash(userId, itemId)
    }
}