com.podio.item.map.converter.NumberConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api Show documentation
Show all versions of api Show documentation
The official Java wrapper for the Podio API
package com.podio.item.map.converter;
import java.math.BigDecimal;
import java.util.Collections;
import java.util.Map;
import org.apache.commons.beanutils.ConvertUtils;
public class NumberConverter implements FieldConverter {
@Override
public Map fromModel(Object value) {
BigDecimal bdValue = (BigDecimal) ConvertUtils.convert(value,
BigDecimal.class);
return Collections.singletonMap("value", bdValue.toPlainString());
}
@Override
public Object toModel(Map map, Class modelClass) {
BigDecimal bdValue = new BigDecimal((String) map.get("value"));
return ConvertUtils.convert(bdValue, modelClass);
}
}