package com.narutohuo.xindazhou.nfc.model

/**
 * NFC响应模型（统一结构）
 * 
 * 遵循统一设计：success, data, errorCode, errorMessage, timestamp
 */
data class NFCResponse(
    /**
     * 是否成功
     */
    val success: Boolean,
    
    /**
     * 响应数据（读取的数据）
     */
    val data: ByteArray? = null,
    
    /**
     * 错误码（如果有错误）
     */
    val errorCode: Int? = null,
    
    /**
     * 错误消息（如果有错误）
     */
    val errorMessage: String? = null,
    
    /**
     * 时间戳
     */
    val timestamp: Long = System.currentTimeMillis()
) {
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as NFCResponse

        if (success != other.success) return false
        if (data != null) {
            if (other.data == null) return false
            if (!data.contentEquals(other.data)) return false
        } else if (other.data != null) return false
        if (errorCode != other.errorCode) return false
        if (errorMessage != other.errorMessage) return false
        if (timestamp != other.timestamp) return false

        return true
    }

    override fun hashCode(): Int {
        var result = success.hashCode()
        result = 31 * result + (data?.contentHashCode() ?: 0)
        result = 31 * result + (errorCode ?: 0)
        result = 31 * result + (errorMessage?.hashCode() ?: 0)
        result = 31 * result + timestamp.hashCode()
        return result
    }
}

