com.github.datalking.common.convert.support.StringToNumberConverterFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of play-mvc Show documentation
Show all versions of play-mvc Show documentation
simple mvc framework based on java servlet.
The newest version!
package com.github.datalking.common.convert.support;
import com.github.datalking.common.convert.converter.Converter;
import com.github.datalking.common.convert.converter.ConverterFactory;
import com.github.datalking.util.NumberUtils;
/**
*/
public final class StringToNumberConverterFactory implements ConverterFactory {
public Converter getConverter(Class targetType) {
return new StringToNumber<>(targetType);
}
private static final class StringToNumber implements Converter {
private final Class targetType;
public StringToNumber(Class targetType) {
this.targetType = targetType;
}
public T convert(String source) {
if (source.length() == 0) {
return null;
}
return NumberUtils.parseNumber(source, this.targetType);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy