| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.ComponentModel; |
| | 6 | | using Azure.Core; |
| | 7 | |
|
| | 8 | | namespace Azure.AI.TextAnalytics |
| | 9 | | { |
| | 10 | | /// <summary> |
| | 11 | | /// Text Analytics warning code values. |
| | 12 | | /// </summary> |
| | 13 | | public readonly struct TextAnalyticsWarningCode : IEquatable<TextAnalyticsWarningCode> |
| | 14 | | { |
| | 15 | | private readonly string _value; |
| | 16 | |
|
| | 17 | | /// <summary> |
| | 18 | | /// Specifies that the warning code is long words in document. |
| | 19 | | /// </summary> |
| 2 | 20 | | public static readonly string LongWordsInDocument = "LongWordsInDocument"; |
| | 21 | |
|
| | 22 | | /// <summary> |
| | 23 | | /// Specifies that the warning code is a document truncated. |
| | 24 | | /// </summary> |
| 2 | 25 | | public static readonly string DocumentTruncated = "DocumentTruncated"; |
| | 26 | |
|
| | 27 | | private TextAnalyticsWarningCode(string warningCode) |
| | 28 | | { |
| 4 | 29 | | Argument.AssertNotNullOrEmpty(warningCode, nameof(warningCode)); |
| 4 | 30 | | _value = warningCode; |
| 4 | 31 | | } |
| | 32 | |
|
| | 33 | | /// <summary> |
| | 34 | | /// Defines implicit conversion from string to TextAnalyticsWarningCode. |
| | 35 | | /// </summary> |
| | 36 | | /// <param name="warningCode">string to convert.</param> |
| | 37 | | /// <returns>The string as an TextAnalyticsWarningCode.</returns> |
| 4 | 38 | | public static implicit operator TextAnalyticsWarningCode(string warningCode) => new TextAnalyticsWarningCode(war |
| | 39 | |
|
| | 40 | | /// <summary> |
| | 41 | | /// Defines explicit conversion from TextAnalyticsWarningCode to string. |
| | 42 | | /// </summary> |
| | 43 | | /// <param name="warningCode">TextAnalyticsWarningCode to convert.</param> |
| | 44 | | /// <returns>The TextAnalyticsWarningCode as a string.</returns> |
| 0 | 45 | | public static explicit operator string(TextAnalyticsWarningCode warningCode) => warningCode._value; |
| | 46 | |
|
| | 47 | | /// <summary> |
| | 48 | | /// Compares two TextAnalyticsWarningCode values for equality. |
| | 49 | | /// </summary> |
| | 50 | | /// <param name="left">The first TextAnalyticsWarningCode to compare.</param> |
| | 51 | | /// <param name="right">The second TextAnalyticsWarningCode to compare.</param> |
| | 52 | | /// <returns>true if the TextAnalyticsWarningCode objects are equal or are both null; false otherwise.</returns> |
| 0 | 53 | | public static bool operator ==(TextAnalyticsWarningCode left, TextAnalyticsWarningCode right) => Equals(left, ri |
| | 54 | |
|
| | 55 | | /// <summary> |
| | 56 | | /// Compares two TextAnalyticsWarningCode values for inequality. |
| | 57 | | /// </summary> |
| | 58 | | /// <param name="left">The first TextAnalyticsWarningCode to compare.</param> |
| | 59 | | /// <param name="right">The second TextAnalyticsWarningCode to compare.</param> |
| | 60 | | /// <returns>true if the TextAnalyticsWarningCode objects are not equal; false otherwise.</returns> |
| 0 | 61 | | public static bool operator !=(TextAnalyticsWarningCode left, TextAnalyticsWarningCode right) => !Equals(left, r |
| | 62 | |
|
| | 63 | | /// <summary> |
| | 64 | | /// Compares the TextAnalyticsWarningCode for equality with another TextAnalyticsWarningCode. |
| | 65 | | /// </summary> |
| | 66 | | /// <param name="other">The TextAnalyticsWarningCode with which to compare.</param> |
| | 67 | | /// <returns><c>true</c> if the TextAnalyticsWarningCode objects are equal; otherwise, <c>false</c>.</returns> |
| 0 | 68 | | public bool Equals(TextAnalyticsWarningCode other) => _value == other._value; |
| | 69 | |
|
| | 70 | | /// <summary> |
| | 71 | | /// Determines whether the specified object is equal to the current object. |
| | 72 | | /// </summary> |
| | 73 | | /// <param name="obj">The object to compare with the current object.</param> |
| | 74 | | /// <returns><c>true</c> if the specified object is equal to the current object; otherwise, <c>false</c>.</retur |
| | 75 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 76 | | public override bool Equals(object obj) => obj is TextAnalyticsWarningCode warningCode && Equals(warningCode); |
| | 77 | |
|
| | 78 | | /// <summary> |
| | 79 | | /// Serves as the default hash function. |
| | 80 | | /// </summary> |
| | 81 | | /// <returns>A hash code for the current object.</returns> |
| | 82 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 83 | | public override int GetHashCode() => _value.GetHashCode(); |
| | 84 | |
|
| | 85 | | /// <summary> |
| | 86 | | /// Returns a string representation of the TextAnalyticsWarningCode. |
| | 87 | | /// </summary> |
| | 88 | | /// <returns>The TextAnalyticsWarningCode as a string.</returns> |
| 4 | 89 | | public override string ToString() => _value; |
| | 90 | | } |
| | 91 | | } |