Namespace Search
    Public Class SearchToken

        Public Class Token
            Public AttributeTitle As String
            Public AttributeId As Integer
            Public TermValue As String
            Public TermId As Integer
        End Class

        Public Class ValueOnlyToken
            Inherits Token

            Public Overrides Function GetHashCode() As Integer
                Return TermId.GetHashCode
            End Function

            Public Overrides Function Equals(obj As Object) As Boolean
                Return GetHashCode() = DirectCast(obj, ValueOnlyToken).GetHashCode()
            End Function

            Public Overrides Function ToString() As String
                Return TermValue
            End Function
        End Class

        Public Class AttributeValueToken
            Inherits Token

            Public Overrides Function GetHashCode() As Integer
                Return (TermId.GetHashCode & AttributeId.GetHashCode).GetHashCode()
            End Function

            Public Overrides Function Equals(obj As Object) As Boolean
                Return Me.GetHashCode() = DirectCast(obj, AttributeValueToken).GetHashCode()
            End Function

            Public Overrides Function ToString() As String
                Return $"{TermValue} ({AttributeTitle})"
            End Function
        End Class

    End Class

End Namespace