EntityRecognitionSkillVersion.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 EntityRecognitionSkill}.
  8.  */
  9. public enum EntityRecognitionSkillVersion {
  10.     /**
  11.      * Version 1 of {@link EntityRecognitionSkill}.
  12.      */
  13.     V1("#Microsoft.Skills.Text.EntityRecognitionSkill"),

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

  18.     @JsonValue
  19.     private final String odataType;

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

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

  31.     /**
  32.      * Gets the {@link EntityRecognitionSkillVersion} 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 EntityRecognitionSkillVersion}.
  37.      * @return The {@link EntityRecognitionSkillVersion} corresponding to the {@code value}, or null if no versions
  38.      * match the {@code value}.
  39.      */
  40.     @JsonCreator
  41.     public static EntityRecognitionSkillVersion 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. }