Class AbstractBaseEnumConfigurationStore
- java.lang.Object
-
- com.github.toolarium.enumeration.configuration.store.impl.AbstractBaseEnumConfigurationStore
-
- All Implemented Interfaces:
IEnumConfigurationStore
- Direct Known Subclasses:
AbstractBaseTypeEnumConfigurationStore
public abstract class AbstractBaseEnumConfigurationStore extends java.lang.Object implements IEnumConfigurationStore
Abstract base enum configuration store.
-
-
Constructor Summary
Constructors Constructor Description AbstractBaseEnumConfigurationStore()
Constructor for AbstractBaseEnumConfigurationStore
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected <T extends java.lang.Enum<T>>
java.lang.StringconvertObjectToString(java.lang.String configurationName, EnumKeyValueConfiguration enumKeyValueConfiguration, java.lang.Object configurationValue)
Convert an object into a stringprotected abstract <D> java.lang.String
deleteConfiguration(java.lang.String configurationKeyName)
Delete the configuration from a source.<D> IEnumConfigurationValue<D>
deleteConfigurationValue(java.lang.String inputConfigurationKeyName)
Deletes a configuration value.java.util.Properties
deleteConfigurationValueList(java.lang.String... inputConfigurationKeyNames)
Deletes a list of configuration values.IEnumConfigurationKeyResolver
getEnumConfigurationKeyResolver()
Get the configuration key resolver.protected EnumKeyValueConfiguration
getEnumKeyValueConfiguration(java.lang.String inputConfigurationKeyName)
Get the enum key / value configuration information of an enum configuration name / key.protected java.lang.String
handlingNullObject(java.lang.Object obj)
Handling of null objectsprotected abstract java.lang.String
loadConfiguration(java.lang.String configurationKeyName)
Load the configuration from a source.protected java.lang.String[]
prepareConfigurationNames(java.lang.String... inputConfigurationKeyNames)
Prepare configuration key namesprotected <D> IEnumConfigurationValue<D>
prepareResult(java.lang.String result, java.util.Collection<D> values)
Prepare resultprotected java.lang.String
prepareValue(EnumKeyValueConfiguration enumKeyValueConfiguration, java.lang.String inputValue, boolean supportReturnDefaultValueIfMissing)
Prepare the read value<D> IEnumConfigurationValue<D>
readConfigurationValue(java.lang.String configurationKey)
Read a configuration value.protected <D> IEnumConfigurationValue<D>
readConfigurationValue(java.lang.String inputConfigurationKeyName, boolean supportReturnDefaultValueIfMissing)
Read a configuration value.<D> IEnumConfigurationValue<D>
readConfigurationValueIgnoreDefault(java.lang.String configurationKey)
Read a configuration value.java.util.Properties
readConfigurationValueList(java.lang.String... inputConfigurationKeyNames)
Read a list of configuration values.java.util.Properties
readConfigurationValueListIgnoreDefault(java.lang.String... inputConfigurationKeyNames)
Read a list of configuration values.protected abstract java.util.Set<java.lang.String>
readKeys()
Read all keys.void
setEnumConfigurationKeyResolver(IEnumConfigurationKeyResolver enumConfigurationKeyResolver)
Sets theIEnumConfigurationKeyResolver
.protected <D> IEnumConfigurationValue<D>
validate(java.lang.String inputConfigurationKeyName, java.lang.String value)
Validate the configuration valueprotected abstract <D> void
writeConfiguration(java.lang.String configurationKeyName, java.lang.String configurationValue)
Write the configuration to a source.<T extends java.lang.Enum<T>>
voidwriteConfigurationValue(java.lang.String inputConfigurationKeyName, java.lang.Object configurationValue)
Write a configuration value.<D> void
writeConfigurationValue(java.lang.String inputConfigurationKeyName, java.lang.String value)
Write a configuration value.void
writeConfigurationValueList(java.util.Properties configuration)
Write a list of configuration values.java.util.Properties
writeConfigurationValueList(java.util.Properties configuration, boolean removeEntriesWithMissingKey)
Write a list of configuration values.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.toolarium.enumeration.configuration.store.IEnumConfigurationStore
deleteConfigurationValue, deleteConfigurationValueList, readConfigurationValue, readConfigurationValueIgnoreDefault, readConfigurationValueList, readConfigurationValueListIgnoreDefault, writeConfigurationValue, writeConfigurationValue
-
-
-
-
Method Detail
-
readConfigurationValue
public <D> IEnumConfigurationValue<D> readConfigurationValue(java.lang.String configurationKey) throws EnumConfigurationStoreException
Description copied from interface:IEnumConfigurationStore
Read a configuration value. In case of missing value a possible defined default value from the enum configuration annotation will be returned.- Specified by:
readConfigurationValue
in interfaceIEnumConfigurationStore
- Type Parameters:
D
- the configuration value type- Parameters:
configurationKey
- the unique configuration key (by default started by the name in lower case and dot notation, separated by#
and the key depending of the IEnumConfigurationKeyResolver).- Returns:
- value the value
- Throws:
EnumConfigurationStoreException
- in case the enum configuration cannot be accessed- See Also:
IEnumConfigurationStore.readConfigurationValue(java.lang.String)
-
readConfigurationValue
protected <D> IEnumConfigurationValue<D> readConfigurationValue(java.lang.String inputConfigurationKeyName, boolean supportReturnDefaultValueIfMissing) throws EnumConfigurationStoreException
Read a configuration value. In case of missing value a possible defined default value from the enum configuration annotation will be returned.- Type Parameters:
D
- the configuration value type- Parameters:
inputConfigurationKeyName
- The unique configuration key, started by the name in lower case and dot notation, separated by#
and the key.supportReturnDefaultValueIfMissing
- true to support default value- Returns:
- value the value
- Throws:
EnumConfigurationStoreException
- in case the enum configuration cannot be read
-
readConfigurationValueIgnoreDefault
public <D> IEnumConfigurationValue<D> readConfigurationValueIgnoreDefault(java.lang.String configurationKey) throws EnumConfigurationStoreException
Description copied from interface:IEnumConfigurationStore
Read a configuration value. In case of missing the value a possible defined default value in the enum configuration will be ignored.- Specified by:
readConfigurationValueIgnoreDefault
in interfaceIEnumConfigurationStore
- Type Parameters:
D
- the configuration value type- Parameters:
configurationKey
- the unique configuration key (by default started by the name in lower case and dot notation, separated by#
and the key depending of the IEnumConfigurationKeyResolver).- Returns:
- value the value
- Throws:
EnumConfigurationStoreException
- in case the enum configuration cannot be accessed- See Also:
IEnumConfigurationStore.readConfigurationValueIgnoreDefault(java.lang.String)
-
writeConfigurationValue
public <D> void writeConfigurationValue(java.lang.String inputConfigurationKeyName, java.lang.String value) throws EnumConfigurationStoreException
Description copied from interface:IEnumConfigurationStore
Write a configuration value.- Specified by:
writeConfigurationValue
in interfaceIEnumConfigurationStore
- Type Parameters:
D
- the configuration value type- Parameters:
inputConfigurationKeyName
- the unique configuration key (by default started by the name in lower case and dot notation, separated by#
and the key depending of the IEnumConfigurationKeyResolver).value
- the value- Throws:
EnumConfigurationStoreException
- in case the enum configuration cannot be written- See Also:
IEnumConfigurationStore.writeConfigurationValue(java.lang.String, java.lang.String)
-
writeConfigurationValue
public <T extends java.lang.Enum<T>> void writeConfigurationValue(java.lang.String inputConfigurationKeyName, java.lang.Object configurationValue) throws EnumConfigurationStoreException
Description copied from interface:IEnumConfigurationStore
Write a configuration value.- Specified by:
writeConfigurationValue
in interfaceIEnumConfigurationStore
- Type Parameters:
T
- the generic configuration name- Parameters:
inputConfigurationKeyName
- the unique configuration key (by default started by the name in lower case and dot notation, separated by#
and the key depending of the IEnumConfigurationKeyResolver).configurationValue
- the value- Throws:
EnumConfigurationStoreException
- in case the enum configuration cannot be written- See Also:
IEnumConfigurationStore.writeConfigurationValue(java.lang.String, java.lang.Object)
-
readConfigurationValueList
public java.util.Properties readConfigurationValueList(java.lang.String... inputConfigurationKeyNames) throws EnumConfigurationStoreException
Description copied from interface:IEnumConfigurationStore
Read a list of configuration values. In case of missing value a possible defined default value from the enum configuration annotation will be returned.- Specified by:
readConfigurationValueList
in interfaceIEnumConfigurationStore
- Parameters:
inputConfigurationKeyNames
- the unique configuration keys (by default started by the name in lower case and dot notation, separated by#
and the key depending of the IEnumConfigurationKeyResolver).- Returns:
- the read configuration properties
- Throws:
EnumConfigurationStoreException
- in case the enum configuration cannot be accessed- See Also:
IEnumConfigurationStore.readConfigurationValueList(java.lang.String[])
-
readConfigurationValueListIgnoreDefault
public java.util.Properties readConfigurationValueListIgnoreDefault(java.lang.String... inputConfigurationKeyNames) throws EnumConfigurationStoreException
Description copied from interface:IEnumConfigurationStore
Read a list of configuration values. In case of missing the value a possible defined default value in the enum configuration will be ignored.- Specified by:
readConfigurationValueListIgnoreDefault
in interfaceIEnumConfigurationStore
- Parameters:
inputConfigurationKeyNames
- the unique configuration keys (by default started by the name in lower case and dot notation, separated by#
and the key depending of the IEnumConfigurationKeyResolver).- Returns:
- the read configuration properties
- Throws:
EnumConfigurationStoreException
- in case the enum configuration cannot be accessed- See Also:
IEnumConfigurationStore.readConfigurationValueListIgnoreDefault(java.lang.String[])
-
writeConfigurationValueList
public void writeConfigurationValueList(java.util.Properties configuration) throws EnumConfigurationStoreException
Description copied from interface:IEnumConfigurationStore
Write a list of configuration values. All other values in the store are not touched.- Specified by:
writeConfigurationValueList
in interfaceIEnumConfigurationStore
- Parameters:
configuration
- the configuration properties where the key corresponds to a valid configuration key- Throws:
EnumConfigurationStoreException
- in case the enum configuration cannot be accessed- See Also:
IEnumConfigurationStore.writeConfigurationValueList(java.util.Properties)
-
writeConfigurationValueList
public java.util.Properties writeConfigurationValueList(java.util.Properties configuration, boolean removeEntriesWithMissingKey) throws EnumConfigurationStoreException
Description copied from interface:IEnumConfigurationStore
Write a list of configuration values. Be careful in case ofremoveEntriesWithMissingKeys = true
, it deletes not covered data.- Specified by:
writeConfigurationValueList
in interfaceIEnumConfigurationStore
- Parameters:
configuration
- the configuration properties where the key corresponds to a valid configuration keyremoveEntriesWithMissingKey
- true to remove all entries on store which are not listed in the over given configuration- Returns:
- the deleted configuration properties
- Throws:
EnumConfigurationStoreException
- in case the enum configuration cannot be accessed- See Also:
IEnumConfigurationStore.writeConfigurationValueList(java.util.Properties, boolean)
-
deleteConfigurationValue
public <D> IEnumConfigurationValue<D> deleteConfigurationValue(java.lang.String inputConfigurationKeyName) throws EnumConfigurationStoreException
Description copied from interface:IEnumConfigurationStore
Deletes a configuration value.- Specified by:
deleteConfigurationValue
in interfaceIEnumConfigurationStore
- Type Parameters:
D
- the configuration value type- Parameters:
inputConfigurationKeyName
- the unique configuration key (by default started by the name in lower case and dot notation, separated by#
and the key depending of the IEnumConfigurationKeyResolver).- Returns:
- the deleted configuration value or null
- Throws:
EnumConfigurationStoreException
- in case the enum configuration cannot be accessed- See Also:
IEnumConfigurationStore.deleteConfigurationValue(java.lang.String)
-
deleteConfigurationValueList
public java.util.Properties deleteConfigurationValueList(java.lang.String... inputConfigurationKeyNames) throws EnumConfigurationStoreException
Description copied from interface:IEnumConfigurationStore
Deletes a list of configuration values.- Specified by:
deleteConfigurationValueList
in interfaceIEnumConfigurationStore
- Parameters:
inputConfigurationKeyNames
- the unique configuration key (by default started by the name in lower case and dot notation, separated by#
and the key depending of the IEnumConfigurationKeyResolver).- Returns:
- the deleted configuration properties where the key corresponds to a valid configuration key
- Throws:
EnumConfigurationStoreException
- in case the enum configuration cannot be accessed- See Also:
IEnumConfigurationStore.deleteConfigurationValueList(java.lang.String[])
-
getEnumConfigurationKeyResolver
public IEnumConfigurationKeyResolver getEnumConfigurationKeyResolver()
Description copied from interface:IEnumConfigurationStore
Get the configuration key resolver.- Specified by:
getEnumConfigurationKeyResolver
in interfaceIEnumConfigurationStore
- Returns:
- the configuration key resolver.
- See Also:
IEnumConfigurationStore.getEnumConfigurationKeyResolver()
-
setEnumConfigurationKeyResolver
public void setEnumConfigurationKeyResolver(IEnumConfigurationKeyResolver enumConfigurationKeyResolver)
Sets theIEnumConfigurationKeyResolver
.- Parameters:
enumConfigurationKeyResolver
- the resolver
-
prepareValue
protected java.lang.String prepareValue(EnumKeyValueConfiguration enumKeyValueConfiguration, java.lang.String inputValue, boolean supportReturnDefaultValueIfMissing)
Prepare the read value- Parameters:
enumKeyValueConfiguration
- the enum key value configurationinputValue
- the read valuesupportReturnDefaultValueIfMissing
- true to support default value- Returns:
- value the value
-
validate
protected <D> IEnumConfigurationValue<D> validate(java.lang.String inputConfigurationKeyName, java.lang.String value) throws EnumConfigurationStoreException
Validate the configuration value- Type Parameters:
D
- the configuration value type- Parameters:
inputConfigurationKeyName
- the configuration key namevalue
- the value- Returns:
- the converted value
- Throws:
EnumConfigurationStoreException
- In case of a load exception
-
prepareResult
protected <D> IEnumConfigurationValue<D> prepareResult(java.lang.String result, java.util.Collection<D> values)
Prepare result- Type Parameters:
D
- the configuration value type- Parameters:
result
- the result to preparevalues
- the corresponding values- Returns:
- the configuration value
-
loadConfiguration
protected abstract java.lang.String loadConfiguration(java.lang.String configurationKeyName) throws EnumConfigurationStoreException
Load the configuration from a source. The configurationKeyName and the value are pure string based.- Parameters:
configurationKeyName
- the unique configuration key- Returns:
- the configuration
- Throws:
EnumConfigurationStoreException
- In case of a load exception
-
writeConfiguration
protected abstract <D> void writeConfiguration(java.lang.String configurationKeyName, java.lang.String configurationValue) throws EnumConfigurationStoreException
Write the configuration to a source. The configurationKeyName and the value are pure string based.- Type Parameters:
D
- the configuration value type- Parameters:
configurationKeyName
- the unique configuration keyconfigurationValue
- the configuration value- Throws:
EnumConfigurationStoreException
- In case of a load exception
-
deleteConfiguration
protected abstract <D> java.lang.String deleteConfiguration(java.lang.String configurationKeyName) throws EnumConfigurationStoreException
Delete the configuration from a source. The configurationKeyName and the value are pure string based.- Type Parameters:
D
- the configuration value type- Parameters:
configurationKeyName
- the unique configuration key- Returns:
- the deleted configuration value
- Throws:
EnumConfigurationStoreException
- In case of a load exception
-
readKeys
protected abstract java.util.Set<java.lang.String> readKeys() throws EnumConfigurationStoreException
Read all keys.- Returns:
- the unique configuration key list
- Throws:
EnumConfigurationStoreException
- In case of a load exception
-
getEnumKeyValueConfiguration
protected EnumKeyValueConfiguration getEnumKeyValueConfiguration(java.lang.String inputConfigurationKeyName) throws EnumConfigurationStoreException
Get the enum key / value configuration information of an enum configuration name / key. It can be get either by interpreting of the annotation of the enum configuration or to load the previous generated JSON from internal / external source.- Parameters:
inputConfigurationKeyName
- the configuration key name- Returns:
- the enum key value configuration
- Throws:
EnumConfigurationStoreException
- In case of an enum configuration store execption
-
convertObjectToString
protected <T extends java.lang.Enum<T>> java.lang.String convertObjectToString(java.lang.String configurationName, EnumKeyValueConfiguration enumKeyValueConfiguration, java.lang.Object configurationValue)
Convert an object into a string- Type Parameters:
T
- the generic type- Parameters:
configurationName
- the configuration nameenumKeyValueConfiguration
- the enum key / value configurationconfigurationValue
- the configuration value- Returns:
- the converted string
-
handlingNullObject
protected java.lang.String handlingNullObject(java.lang.Object obj)
Handling of null objects- Parameters:
obj
- the object- Returns:
- the string
-
prepareConfigurationNames
protected java.lang.String[] prepareConfigurationNames(java.lang.String... inputConfigurationKeyNames) throws EnumConfigurationStoreException
Prepare configuration key names- Parameters:
inputConfigurationKeyNames
- the input name list. In case it's null or empty then all keys will be read- Returns:
- the configuration key names to read
- Throws:
EnumConfigurationStoreException
- in case the enum configuration cannot be accessed
-
-