SentimentSkillVersion.java

  1. // Copyright (c) Microsoft Corporation. All rights reserved.
  2. // Licensed under the MIT License.

  3. package com.azure.search.documents.indexes.models;

  4. import com.fasterxml.jackson.annotation.JsonCreator;
  5. import com.fasterxml.jackson.annotation.JsonValue;

  6. /**
  7.  * Represents the version of {@link SentimentSkill}.
  8.  */
  9. public enum SentimentSkillVersion {
  10.     /**
  11.      * Version 1 of {@link SentimentSkill}.
  12.      */
  13.     V1("#Microsoft.Skills.Text.SentimentSkill"),

  14.     /**
  15.      * Version 3 of {@link SentimentSkill}.
  16.      */
  17.     V3("#Microsoft.Skills.Text.V3.SentimentSkill");

  18.     @JsonValue
  19.     private final String odataType;

  20.     SentimentSkillVersion(String odataType) {
  21.         this.odataType = odataType;
  22.     }

  23.     /**
  24.      * Gets the latest {@link SentimentSkill} version.
  25.      *
  26.      * @return The latest {@link SentimentSkill} version.
  27.      */
  28.     public static SentimentSkillVersion getLatest() {
  29.         return V3;
  30.     }

  31.     /**
  32.      * Gets the {@link SentimentSkillVersion} from the string {@code value}.
  33.      * <p>
  34.      * If the {@code value} doesn't match any version null will be returned.
  35.      *
  36.      * @param value The value to convert to an {@link SentimentSkillVersion}.
  37.      * @return The {@link SentimentSkillVersion} corresponding to the {@code value}, or null if no versions match the
  38.      * {@code value}.
  39.      */
  40.     @JsonCreator
  41.     public static SentimentSkillVersion fromString(String value) {
  42.         if (V1.odataType.equals(value)) {
  43.             return V1;
  44.         } else if (V3.odataType.equals(value)) {
  45.             return V3;
  46.         } else {
  47.             return null;
  48.         }
  49.     }

  50.     @Override
  51.     public String toString() {
  52.         return odataType;
  53.     }
  54. }