PatternAnalyzer.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. import com.fasterxml.jackson.annotation.JsonSetter;
  12. import com.fasterxml.jackson.annotation.JsonTypeId;
  13. import com.fasterxml.jackson.annotation.JsonTypeInfo;
  14. import com.fasterxml.jackson.annotation.JsonTypeName;
  15. import java.util.List;
  16. import java.util.stream.Collectors;

  17. /**
  18.  * Flexibly separates text into terms via a regular expression pattern. This analyzer is implemented using Apache
  19.  * Lucene.
  20.  */
  21. @JsonTypeInfo(
  22.         use = JsonTypeInfo.Id.NAME,
  23.         include = JsonTypeInfo.As.EXISTING_PROPERTY,
  24.         property = "@odata.type",
  25.         visible = true)
  26. @JsonTypeName("#Microsoft.Azure.Search.PatternAnalyzer")
  27. @Fluent
  28. public final class PatternAnalyzer extends LexicalAnalyzer {

  29.     /*
  30.      * Identifies the concrete type of the analyzer.
  31.      */
  32.     @JsonTypeId
  33.     @JsonProperty(value = "@odata.type", required = true)
  34.     private String odataType = "#Microsoft.Azure.Search.PatternAnalyzer";

  35.     /*
  36.      * A value indicating whether terms should be lower-cased. Default is true.
  37.      */
  38.     @JsonProperty(value = "lowercase")
  39.     private Boolean lowerCaseTerms;

  40.     /*
  41.      * A regular expression pattern to match token separators. Default is an
  42.      * expression that matches one or more non-word characters.
  43.      */
  44.     @JsonProperty(value = "pattern")
  45.     private String pattern;

  46.     /*
  47.      * Regular expression flags.
  48.      */
  49.     @JsonProperty(value = "flags")
  50.     private RegexFlags flags;

  51.     /*
  52.      * A list of stopwords.
  53.      */
  54.     @JsonProperty(value = "stopwords")
  55.     private List<String> stopwords;

  56.     /**
  57.      * Creates an instance of PatternAnalyzer class.
  58.      *
  59.      * @param name the name value to set.
  60.      */
  61.     @JsonCreator
  62.     public PatternAnalyzer(@JsonProperty(value = "name", required = true) String name) {
  63.         super(name);
  64.     }

  65.     /**
  66.      * Get the lowerCaseTerms property: A value indicating whether terms should be lower-cased. Default is true.
  67.      *
  68.      * @return the lowerCaseTerms value.
  69.      */
  70.     public Boolean areLowerCaseTerms() {
  71.         return this.lowerCaseTerms;
  72.     }

  73.     /**
  74.      * Set the lowerCaseTerms property: A value indicating whether terms should be lower-cased. Default is true.
  75.      *
  76.      * @param lowerCaseTerms the lowerCaseTerms value to set.
  77.      * @return the PatternAnalyzer object itself.
  78.      */
  79.     public PatternAnalyzer setLowerCaseTerms(Boolean lowerCaseTerms) {
  80.         this.lowerCaseTerms = lowerCaseTerms;
  81.         return this;
  82.     }

  83.     /**
  84.      * Get the pattern property: A regular expression pattern to match token separators. Default is an expression that
  85.      * matches one or more non-word characters.
  86.      *
  87.      * @return the pattern value.
  88.      */
  89.     public String getPattern() {
  90.         return this.pattern;
  91.     }

  92.     /**
  93.      * Set the pattern property: A regular expression pattern to match token separators. Default is an expression that
  94.      * matches one or more non-word characters.
  95.      *
  96.      * @param pattern the pattern value to set.
  97.      * @return the PatternAnalyzer object itself.
  98.      */
  99.     public PatternAnalyzer setPattern(String pattern) {
  100.         this.pattern = pattern;
  101.         return this;
  102.     }

  103.     /**
  104.      * Get the flags property: Regular expression flags.
  105.      *
  106.      * @return the flags value.
  107.      */
  108.     public List<RegexFlags> getFlags() {
  109.         if (this.flags == null) {
  110.             return null;
  111.         } else {
  112.             String[] flagStrings = this.flags.toString().split("\\|");
  113.             return java.util.Arrays.stream(flagStrings).map(RegexFlags::fromString).collect(Collectors.toList());
  114.         }
  115.     }

  116.     /**
  117.      * Set the flags property: Regular expression flags.
  118.      *
  119.      * @param flags the flags value to set.
  120.      * @return the PatternAnalyzer object itself.
  121.      */
  122.     @JsonSetter
  123.     public PatternAnalyzer setFlags(List<RegexFlags> flags) {
  124.         if (flags == null) {
  125.             this.flags = null;
  126.         } else {
  127.             String flagString = flags.stream().map(RegexFlags::toString).collect(Collectors.joining("|"));
  128.             this.flags = RegexFlags.fromString(flagString);
  129.         }

  130.         return this;
  131.     }

  132.     /**
  133.      * Get the stopwords property: A list of stopwords.
  134.      *
  135.      * @return the stopwords value.
  136.      */
  137.     public List<String> getStopwords() {
  138.         return this.stopwords;
  139.     }

  140.     /**
  141.      * Set the stopwords property: A list of stopwords.
  142.      *
  143.      * @param stopwords the stopwords value to set.
  144.      * @return the PatternAnalyzer object itself.
  145.      */
  146.     @JsonSetter
  147.     public PatternAnalyzer setStopwords(List<String> stopwords) {
  148.         this.stopwords = stopwords;
  149.         return this;
  150.     }

  151.     /**
  152.      * Set the stopwords property: A list of stopwords.
  153.      *
  154.      * @param stopwords the stopwords value to set.
  155.      * @return the PatternAnalyzer object itself.
  156.      */
  157.     public PatternAnalyzer setStopwords(String... stopwords) {
  158.         this.stopwords = (stopwords == null) ? null : java.util.Arrays.asList(stopwords);
  159.         return this;
  160.     }

  161.     /**
  162.      * Set the flags property: Regular expression flags.
  163.      *
  164.      * @param flags the flags value to set.
  165.      * @return the PatternAnalyzer object itself.
  166.      */
  167.     public PatternAnalyzer setFlags(RegexFlags... flags) {
  168.         if (flags == null) {
  169.             this.flags = null;
  170.             return this;
  171.         } else {
  172.             return setFlags(java.util.Arrays.asList(flags));
  173.         }
  174.     }
  175. }