using System; using System.Diagnostics; namespace BotSharp.Algorithm.Bayesian { /// /// Class StringToken. This class cannot be inherited. /// [DebuggerDisplay("{Value}")] public sealed class StringToken : IToken { /// /// Gets the value. /// /// The value. public string Value { get; private set; } /// /// Initializes a new instance of the class. /// /// The value. public StringToken(string value) { if (ReferenceEquals(value, null)) throw new ArgumentNullException("value"); Value = value; } /// /// Determines whether the specified is equal to this instance. /// /// The to compare with the current . /// if the specified is equal to this instance; otherwise, . private bool Equals(StringToken other) { return string.Equals(Value, other.Value); } /// /// Determines whether the specified is equal to this instance. /// /// The to compare with the current . /// if the specified is equal to this instance; otherwise, . bool IEquatable.Equals(IToken other) { var otherAsObject = (object)other; return Equals(otherAsObject); } /// /// Determines whether the specified is equal to this instance. /// /// The to compare with the current . /// if the specified is equal to this instance; otherwise, . public override bool Equals(object obj) { // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; return obj is StringToken && Equals((StringToken) obj); } /// /// Returns a hash code for this instance. /// /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. public override int GetHashCode() { return Value.GetHashCode(); } /// /// Returns a that represents this instance. /// /// A that represents this instance. public override string ToString() { return Value; } } }