Class DefaultConfigurationRepository
- java.lang.Object
-
- com.snowflake.connectors.application.configuration.DefaultConfigurationRepository
-
- All Implemented Interfaces:
ConfigurationRepository
public class DefaultConfigurationRepository extends Object implements ConfigurationRepository
Default implementation ofConfigurationRepository
, which uses theKeyValueTable
for data storage.
-
-
Field Summary
-
Fields inherited from interface com.snowflake.connectors.application.configuration.ConfigurationRepository
CONNECTION_CONFIGURATION_KEY, CONNECTOR_CONFIGURATION_KEY
-
-
Constructor Summary
Constructors Constructor Description DefaultConfigurationRepository(KeyValueTable table)
Creates a newDefaultConfigurationRepository
, using the provided table for data storage.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
delete(String key)
Deletes the configuration record stored under the provided key.<T> Optional<T>
fetch(String key, Class<T> clazz)
Retrieves configuration properties from the record stored under the provided key, and maps them to the provided class.ConfigurationMap
fetchAll()
Retrieves all configuration records and maps them to anConfigurationMap
instance.<T> void
update(String key, T value)
Updates the configuration properties in the record stored under the provided key.
-
-
-
Constructor Detail
-
DefaultConfigurationRepository
public DefaultConfigurationRepository(KeyValueTable table)
Creates a newDefaultConfigurationRepository
, using the provided table for data storage.- Parameters:
table
- key-value table used for data storage
-
-
Method Detail
-
fetch
public <T> Optional<T> fetch(String key, Class<T> clazz)
Description copied from interface:ConfigurationRepository
Retrieves configuration properties from the record stored under the provided key, and maps them to the provided class.- Specified by:
fetch
in interfaceConfigurationRepository
- Type Parameters:
T
- type of the provided class- Parameters:
key
- key of the configuration recordclazz
- a class to which the retrieved properties will be mapped- Returns:
- an object of a given class, created by mapping the retrieved configuration properties
-
update
public <T> void update(String key, T value)
Description copied from interface:ConfigurationRepository
Updates the configuration properties in the record stored under the provided key. If the configuration is not present, a new record will be created.- Specified by:
update
in interfaceConfigurationRepository
- Type Parameters:
T
- type of the provided value- Parameters:
key
- key of the configuration recordvalue
- new configuration properties
-
fetchAll
public ConfigurationMap fetchAll()
Description copied from interface:ConfigurationRepository
Retrieves all configuration records and maps them to anConfigurationMap
instance.- Specified by:
fetchAll
in interfaceConfigurationRepository
- Returns:
- a configuration map containing all retrieved configuration records
-
delete
public void delete(String key)
Description copied from interface:ConfigurationRepository
Deletes the configuration record stored under the provided key. If the record does not exist, then no action is taken.- Specified by:
delete
in interfaceConfigurationRepository
- Parameters:
key
- key of the configuration record
-
-