CreateOrUpdateDataSourceConnectionOptions.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 java.util.Objects;

  5. /**
  6.  * This model represents a property bag containing all options for creating or updating a {@link
  7.  * SearchIndexerDataSourceConnection data source connection}.
  8.  */
  9. public final class CreateOrUpdateDataSourceConnectionOptions {
  10.     private final SearchIndexerDataSourceConnection dataSourceConnection;

  11.     private boolean onlyIfUnchanged;
  12.     private Boolean cacheResetRequirementsIgnored;

  13.     /**
  14.      * Creates the property bag used to create or update a {@link SearchIndexerDataSourceConnection data source
  15.      * connection}.
  16.      *
  17.      * @param dataSourceConnection The {@link SearchIndexerDataSourceConnection data source connection} being created or
  18.      * updated.
  19.      * @throws NullPointerException If {@code dataSourceConnection} is null.
  20.      */
  21.     public CreateOrUpdateDataSourceConnectionOptions(SearchIndexerDataSourceConnection dataSourceConnection) {
  22.         this.dataSourceConnection = Objects.requireNonNull(dataSourceConnection,
  23.             "'dataSourceConnection' cannot be null.");
  24.     }

  25.     /**
  26.      * Gets the {@link SearchIndexerDataSourceConnection data source connection} that will be created or updated.
  27.      *
  28.      * @return The {@link SearchIndexerDataSourceConnection data source connection} that will be created or updated.
  29.      */
  30.     public SearchIndexerDataSourceConnection getDataSourceConnection() {
  31.         return dataSourceConnection;
  32.     }

  33.     /**
  34.      * Sets the flag that determines whether an update will only occur if the {@link SearchIndexerDataSourceConnection
  35.      * data source connection} has not been changed since the update has been triggered.
  36.      *
  37.      * @param onlyIfUnchanged Flag that determines whether an update will only occur if the {@link
  38.      * SearchIndexerDataSourceConnection data source connection} has not been changed since the update has been
  39.      * triggered.
  40.      * @return The updated CreateOrUpdateDataSourceConnectionOptions object.
  41.      */
  42.     public CreateOrUpdateDataSourceConnectionOptions setOnlyIfUnchanged(boolean onlyIfUnchanged) {
  43.         this.onlyIfUnchanged = onlyIfUnchanged;
  44.         return this;
  45.     }

  46.     /**
  47.      * Gets the flag that determines whether an update will only occur if the {@link SearchIndexerDataSourceConnection
  48.      * data source connection} has not been changed since the update has been triggered.
  49.      *
  50.      * @return Whether an update will only occur if the {@link SearchIndexerDataSourceConnection data source connection}
  51.      * has not been changed since the update has been triggered.
  52.      */
  53.     public boolean isOnlyIfUnchanged() {
  54.         return onlyIfUnchanged;
  55.     }

  56.     /**
  57.      * Sets an optional flag that determines whether the created or updated {@link SearchIndexerDataSourceConnection
  58.      * data source connection} ignores cache reset requirements.
  59.      *
  60.      * @param cacheResetRequirementsIgnored An optional flag that determines whether the created or updated {@link
  61.      * SearchIndexerDataSourceConnection data source connection} ignores cache reset requirements.
  62.      * @return The updated CreateOrUpdateDataSourceConnectionOptions object.
  63.      */
  64.     public CreateOrUpdateDataSourceConnectionOptions setCacheResetRequirementsIgnored(Boolean cacheResetRequirementsIgnored) {
  65.         this.cacheResetRequirementsIgnored = cacheResetRequirementsIgnored;
  66.         return this;
  67.     }

  68.     /**
  69.      * Gets an optional flag that determines whether the created or updated {@link SearchIndexerDataSourceConnection
  70.      * data source connection} ignores cache reset requirements.
  71.      *
  72.      * @return Whether the created or updated {@link SearchIndexerDataSourceConnection data source connection} ignores
  73.      * cache reset requirements.
  74.      */
  75.     public Boolean isCacheResetRequirementsIgnored() {
  76.         return cacheResetRequirementsIgnored;
  77.     }
  78. }