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

com.yuehuanghun.mybatis.milu.tool.converter.impl.BigDecimalConverter Maven / Gradle / Ivy

There is a newer version: 1.18.0
Show newest version
package com.yuehuanghun.mybatis.milu.tool.converter.impl;

import java.math.BigDecimal;

import com.yuehuanghun.mybatis.milu.tool.StringUtils;
import com.yuehuanghun.mybatis.milu.tool.converter.Converter;

public class BigDecimalConverter implements Converter{

	@Override
	public BigDecimal convert(Object target) {
		if(target == null) {
			return null;
		}
		if(CharSequence.class.isInstance(target)) {
			if(StringUtils.isBlank((CharSequence) target)) {
				return null;
			}
			return new BigDecimal(target.toString());
		}
		if(BigDecimal.class == target.getClass()) {
			return (BigDecimal) target;
		}
		return new BigDecimal(target.toString());
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy