mercredi 22 mai 2019

Populate Java Object using Map

I have a Map<String, Object> . Using this, I have to populate one java object. For example,

public void setBaseAttributes(BaseObject baseObj) {
  Map<String, Object> map = // some method call;
  org.apache.commons.beanutils.BeanUtils.populate(baseObj, map);
 }

I was using BeanUtils but got stuck since BeanUtils does not handle BigDecimal. My baseObj has BigDecimal and i can not get rid of it.

Question to experts are:

  • Is there a better alternative i can use here?
  • Using BeanUtils, can we do something to handle BigDecimal also?




Aucun commentaire:

Enregistrer un commentaire