I have ProductSettings
and ProductType
. Product settings determine whether product types are enabled or not.
ProductSettings productSettings = new ProductSettings() .setIsTreasuryInfoEnabled(true) .setIsTreasurySwiftInfoEnabled(true) .setIsTreasuryExecutionControlEnabled(true) .setIsAcceptEnabled(true);public enum ProductType {INFO,INFOSWIFT,BUDGETCONTROL,ACCEPT,DIRECTACCOUNTCONTROL
how can i fill the enabledProductTypes
set using functional interfaces and vs task - enable settings by having product types?
Set<ProductType> enabledProductTypes = EnumSet.noneOf(ProductType.class);
I created map
static Map<ProductType, Predicate<ProductSettings>> mapGetter = new HashMap<>();static Map<ProductType, BiConsumer<ProductSettings, Boolean>> mapSetter = new HashMap<>();
and filled out mapGetter
with Predicate like this:
mapGetter.put(ProductType.ACCEPT, ProductSettings::getIsAcceptEnabled);mapGetter.put(ProductType.INFO,ProductSettings::getIsTreasuryInfoEnabled);
and filled out mapSetter
with BiConsumer like this:
mapSetter.put(ProductType.ACCEPT, ProductSettings::setIsAcceptEnabled);mapSetter.put(ProductType.INFO, ProductSettings::setIsTreasuryInfoEnabled);
but how to use it I can't understand.I guess i shoul iterate by my map