Implement params convert after lombok mapping

試著忘記壹切 提交于 2019-12-11 19:07:43

问题


I want to use Lombook framework and to extend the Java Class that I map. Currently I use this:

// @Mapper(config = BaseMapperConfig.class)
public interface MerchantsMapper {

    MerchantNewDTO toNewDTO(Merchants merchant);
}

Custom implementation:

public MerchantNewDTO toNewDTO(Merchants merchant)
  {
    MerchantNewDTO merchantNewDTO = new MerchantNewDTO();

    merchantNewDTO.setId(Integer.valueOf(merchant.getId()));
    ......

    MerchantConfigurationUtils merchant_config = new MerchantConfigurationUtils();
    Map<MerchantConfigurationFeatureBitString, Boolean> features = merchant_config.initFromDatabaseValue(merchant.getSupported_features());

    merchantNewDTO.setSupports_api(features.get(MerchantConfigurationFeatureBitString.Supports_api));

    return merchantNewDTO;
  }

As you can see I want to get getSupported_features and to populate the Supports_api value.

But it's very painful process to add new values. Is there some way to create adapter which extends the mapped interface and set/get the values?

来源:https://stackoverflow.com/questions/57384982/implement-params-convert-after-lombok-mapping

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!