jodd.typeconverter.impl.MutableDoubleConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jodd-core Show documentation
Show all versions of jodd-core Show documentation
Jodd Core tools and utilities, including type converters, JDateTime, cache etc.
// Copyright (c) 2003-2014, Jodd Team (jodd.org). All Rights Reserved.
package jodd.typeconverter.impl;
import jodd.mutable.MutableDouble;
import jodd.typeconverter.TypeConverter;
import jodd.typeconverter.TypeConverterManagerBean;
/**
* Converts given object to {@link MutableDouble}.
*/
public class MutableDoubleConverter implements TypeConverter {
protected final TypeConverter typeConverter;
@SuppressWarnings("unchecked")
public MutableDoubleConverter(TypeConverterManagerBean typeConverterManagerBean) {
typeConverter = typeConverterManagerBean.lookup(Double.class);
}
public MutableDouble convert(Object value) {
if (value == null) {
return null;
}
if (value.getClass() == MutableDouble.class) {
return (MutableDouble) value;
}
return new MutableDouble(typeConverter.convert(value));
}
}