
struct LocalizedItemId {

    let language: ContentLanguage

    let itemType: ItemReference
}

extension LocalizedItemId: Equatable {

    static func == (lhs: LocalizedItemId, rhs: LocalizedItemId) -> Bool {
        lhs.language == rhs.language &&
        lhs.itemType == rhs.itemType
    }
}

extension LocalizedItemId: Hashable {

    func hash(into hasher: inout Hasher) {
        hasher.combine(language)
        hasher.combine(itemType.id)
    }
}

extension LocalizedItemId: Comparable {
    
    static func < (lhs: LocalizedItemId, rhs: LocalizedItemId) -> Bool {
        guard lhs.itemType == rhs.itemType else {
            return lhs.itemType < rhs.itemType
        }
        return lhs.language < rhs.language
    }
}

extension LocalizedItemId: CustomStringConvertible {

    var description: String {
        "\(itemType) (\(language))"
    }
}
