com.neko233.config233.reader.convert.impl.FloatConvertTextValueStrategy.kt Maven / Gradle / Ivy
The newest version!
package com.neko233.config233.reader.convert.impl
import com.neko233.config233.reader.convert.JavaTypeConvertTextValueStrategy
import java.math.BigDecimal
class FloatConvertTextValueStrategy : JavaTypeConvertTextValueStrategy {
override fun dataType(): Class = Float::class.java
override fun convert(colValue: String): Float? {
return try {
BigDecimal(colValue).toFloat()
} catch (e: NumberFormatException) {
null
}
}
}