-
- All Implemented Interfaces:
public interface KeyValueConfigurationContext<K extends Object>As defined in KeyValueConfigurer documentation, sometimes we need to configure target DataModificationStrategy with respect to some info available in runtime. This interface defines contract for such dynamic info.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classKeyValueConfigurationContext.Companion
-
Method Summary
Modifier and Type Method Description abstract ObjectgetByStaticKey(K key)Target configuration rules might be defined as below: Take current runtime value for key
key1If that value is equal to
baseValue1then usederivedValue1If that value is equal to
baseValue2then usederivedValue2Else use
derivedValue3
abstract ObjectgetByDynamicKey(String key)We might have a finite state of possible keys (e.g. -
-
Method Detail
-
getByStaticKey
abstract Object getByStaticKey(K key)
Target configuration rules might be defined as below:
Take current runtime value for key
key1If that value is equal to
baseValue1then usederivedValue1If that value is equal to
baseValue2then usederivedValue2Else use
derivedValue3
This method defines contract for obtaining base dynamic value for the given key from the given context.
-
getByDynamicKey
abstract Object getByDynamicKey(String key)
We might have a finite state of possible keys (e.g. values of some enum) but want to allow flexible configuration based on some custom key as well.
Example: suppose that target DataModificationStrategy is a result of database select, essentially a collection of column names to their row values. Keys set is finite here - all columns in that table. Let's assume that we want to modify value for particular column based on some meta-info. For example, use different values when we work with different database types (like oracle vs mysql). We can define such config rules as below:
If
<db-type> = oraclethen useoracleValueIf
<db-type> = mysqlthen usemysqlValueElse don't modify the value
In this situation
db-typeis a custom dynamic key and target KeyValueConfigurationContext implementation should be aware of it
-
-
-