All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.podio.item.map.converter.NumberConverter Maven / Gradle / Ivy

There is a newer version: 0.7.9
Show newest version
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);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy