SynonymMap.java

  1. // Copyright (c) Microsoft Corporation. All rights reserved.
  2. // Licensed under the MIT License.
  3. //
  4. // Code generated by Microsoft (R) AutoRest Code Generator.
  5. // Changes may cause incorrect behavior and will be lost if the code is
  6. // regenerated.

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

  8. import com.azure.core.annotation.Fluent;
  9. import com.fasterxml.jackson.annotation.JsonCreator;
  10. import com.fasterxml.jackson.annotation.JsonProperty;

  11. /** Represents a synonym map definition. */
  12. @Fluent
  13. public final class SynonymMap {
  14.     /*
  15.      * The name of the synonym map.
  16.      */
  17.     @JsonProperty(value = "name")
  18.     private String name;

  19.     /*
  20.      * The format of the synonym map. Only the 'solr' format is currently
  21.      * supported.
  22.      */
  23.     @JsonProperty(value = "format")
  24.     private String format = "solr";

  25.     /*
  26.      * A series of synonym rules in the specified synonym map format. The rules
  27.      * must be separated by newlines.
  28.      */
  29.     @JsonProperty(value = "synonyms")
  30.     private String synonyms;

  31.     /*
  32.      * A description of an encryption key that you create in Azure Key Vault.
  33.      * This key is used to provide an additional level of encryption-at-rest
  34.      * for your data when you want full assurance that no one, not even
  35.      * Microsoft, can decrypt your data in Azure Cognitive Search. Once you
  36.      * have encrypted your data, it will always remain encrypted. Azure
  37.      * Cognitive Search will ignore attempts to set this property to null. You
  38.      * can change this property as needed if you want to rotate your encryption
  39.      * key; Your data will be unaffected. Encryption with customer-managed keys
  40.      * is not available for free search services, and is only available for
  41.      * paid services created on or after January 1, 2019.
  42.      */
  43.     @JsonProperty(value = "encryptionKey")
  44.     private SearchResourceEncryptionKey encryptionKey;

  45.     /*
  46.      * The ETag of the synonym map.
  47.      */
  48.     @JsonProperty(value = "@odata.etag")
  49.     private String eTag;

  50.     /**
  51.      * Constructor of {@link SynonymMap}.
  52.      *
  53.      * @param name The name of the synonym map.
  54.      */
  55.     public SynonymMap(String name) {
  56.         this(name, null);
  57.     }

  58.     /**
  59.      * Constructor of {@link SynonymMap}.
  60.      *
  61.      * @param name The name of the synonym map.
  62.      * @param synonyms A series of synonym rules in the specified synonym map format. The rules must be separated by
  63.      *     newlines.
  64.      */
  65.     @JsonCreator
  66.     public SynonymMap(@JsonProperty(value = "name") String name, @JsonProperty(value = "synonyms") String synonyms) {
  67.         this.format = "solr";
  68.         this.name = name;
  69.         this.synonyms = synonyms;
  70.     }

  71.     /**
  72.      * Get the name property: The name of the synonym map.
  73.      *
  74.      * @return the name value.
  75.      */
  76.     public String getName() {
  77.         return this.name;
  78.     }

  79.     /**
  80.      * Get the synonyms property: A series of synonym rules in the specified synonym map format. The rules must be
  81.      * separated by newlines.
  82.      *
  83.      * @return the synonyms value.
  84.      */
  85.     public String getSynonyms() {
  86.         return this.synonyms;
  87.     }

  88.     /**
  89.      * Set the synonyms property: A series of synonym rules in the specified synonym map format. The rules must be
  90.      * separated by newlines.
  91.      *
  92.      * @param synonyms the synonyms value to set.
  93.      * @return the SynonymMap object itself.
  94.      */
  95.     public SynonymMap setSynonyms(String synonyms) {
  96.         this.synonyms = synonyms;
  97.         return this;
  98.     }

  99.     /**
  100.      * Get the encryptionKey property: A description of an encryption key that you create in Azure Key Vault. This key
  101.      * is used to provide an additional level of encryption-at-rest for your data when you want full assurance that no
  102.      * one, not even Microsoft, can decrypt your data in Azure Cognitive Search. Once you have encrypted your data, it
  103.      * will always remain encrypted. Azure Cognitive Search will ignore attempts to set this property to null. You can
  104.      * change this property as needed if you want to rotate your encryption key; Your data will be unaffected.
  105.      * Encryption with customer-managed keys is not available for free search services, and is only available for paid
  106.      * services created on or after January 1, 2019.
  107.      *
  108.      * @return the encryptionKey value.
  109.      */
  110.     public SearchResourceEncryptionKey getEncryptionKey() {
  111.         return this.encryptionKey;
  112.     }

  113.     /**
  114.      * Set the encryptionKey property: A description of an encryption key that you create in Azure Key Vault. This key
  115.      * is used to provide an additional level of encryption-at-rest for your data when you want full assurance that no
  116.      * one, not even Microsoft, can decrypt your data in Azure Cognitive Search. Once you have encrypted your data, it
  117.      * will always remain encrypted. Azure Cognitive Search will ignore attempts to set this property to null. You can
  118.      * change this property as needed if you want to rotate your encryption key; Your data will be unaffected.
  119.      * Encryption with customer-managed keys is not available for free search services, and is only available for paid
  120.      * services created on or after January 1, 2019.
  121.      *
  122.      * @param encryptionKey the encryptionKey value to set.
  123.      * @return the SynonymMap object itself.
  124.      */
  125.     public SynonymMap setEncryptionKey(SearchResourceEncryptionKey encryptionKey) {
  126.         this.encryptionKey = encryptionKey;
  127.         return this;
  128.     }

  129.     /**
  130.      * Get the eTag property: The ETag of the synonym map.
  131.      *
  132.      * @return the eTag value.
  133.      */
  134.     public String getETag() {
  135.         return this.eTag;
  136.     }

  137.     /**
  138.      * Set the eTag property: The ETag of the synonym map.
  139.      *
  140.      * @param eTag the eTag value to set.
  141.      * @return the SynonymMap object itself.
  142.      */
  143.     public SynonymMap setETag(String eTag) {
  144.         this.eTag = eTag;
  145.         return this;
  146.     }

  147.     /**
  148.      * Creates a new instance of SynonymMap with synonyms read from the passed file.
  149.      *
  150.      * @param name The name of the synonym map.
  151.      * @param filePath The path to the file where the formatted synonyms are read.
  152.      * @return A SynonymMap.
  153.      * @throws java.io.UncheckedIOException If reading {@code filePath} fails.
  154.      */
  155.     public static SynonymMap createFromFile(String name, java.nio.file.Path filePath) {
  156.         String synonyms = com.azure.search.documents.implementation.util.Utility.readSynonymsFromFile(filePath);
  157.         return new SynonymMap(name, synonyms);
  158.     }
  159. }