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

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

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

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

public class FloatConverter implements Converter{

	@Override
	public Float convert(Object target) {
		if(target == null) {
			return null;
		}
		if(CharSequence.class.isInstance(target)) {
			if(StringUtils.isBlank((CharSequence) target)) {
				return null;
			}
			return Float.parseFloat(target.toString());
		}
		if(Float.class == target.getClass()) {
			return (Float) target;
		}
		if(Number.class.isInstance(target)) {
			return ((Number) target).floatValue();
		}
		return Float.valueOf(target.toString());
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy