I'm trying to retain a few business configs on the domain through yaml
file.
Structure of yml
config file:
bank:
accountType1:
debit:
- Product1
- Product2
hybrid:
- ProductX
- ProductY
accountType2:
debit:
- Product1
- Product2
- Product3
hybrid:
- ProductX
- ProductY
- ProductZ
I have the below enums for on the domain.
enum AccountType{ ACCOUNT_TYPE1, ACCOUNT_TYPE2}
enum Feature{ DEBIT, HYBRID}
enum Products { Product1, Product2, Product3, ProductX, ProductY, ProductZ }
I would like to seek help to get these business configs as a MultikeyMap, or a nested map, but using enums as keys. For eg:
Map<AccountType, Map<Feature, List<Products>>
Basically I would like the config to perform the following lookup:
if AccountType = accountType1 & Feature = debit, then return [Product1,Product2]
I couldn't find a way to do this elegantly via config files, as it always initialises to null
@ConfigurationProperties(prefix="bank")
public class ProductResolver {
Map<AccountType, Map<Feature, List<Products>> configMap
// NestedMap, Apache MultiKeymap or something similar either should be ok for me
}
Any experts, please could you guide me?