com.neko233.config233.reader.convert.impl.DoubleConvertTextValueStrategy.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 DoubleConvertTextValueStrategy : JavaTypeConvertTextValueStrategy {
override fun dataType(): Class = Double::class.java
override fun convert(colValue: String): Double? {
return try {
BigDecimal(colValue).toDouble()
} catch (e: NumberFormatException) {
null
}
}
}