mirror of
https://github.com/HighCapable/Gropify.git
synced 2025-12-11 15:53:54 +08:00
fix: improve numeric type determination logic in Generator
This commit is contained in:
@@ -56,12 +56,17 @@ internal fun Any.createTypedValue(autoConversion: Boolean): Pair<KClass<*>, Stri
|
|||||||
trimmed.isNumeric() ->
|
trimmed.isNumeric() ->
|
||||||
if (!trimmed.contains(".")) {
|
if (!trimmed.contains(".")) {
|
||||||
val longValue = trimmed.toLongOrNull()
|
val longValue = trimmed.toLongOrNull()
|
||||||
when {
|
when (longValue) {
|
||||||
longValue == null -> String::class
|
null -> String::class
|
||||||
longValue > Int.MAX_VALUE -> Long::class
|
in Int.MIN_VALUE..Int.MAX_VALUE -> Int::class
|
||||||
else -> Int::class
|
else -> Long::class
|
||||||
}
|
}
|
||||||
} else Double::class
|
} else {
|
||||||
|
val doubleValue = trimmed.toDoubleOrNull()
|
||||||
|
if (doubleValue == null || doubleValue.isInfinite())
|
||||||
|
String::class
|
||||||
|
else Double::class
|
||||||
|
}
|
||||||
else -> String::class
|
else -> String::class
|
||||||
}
|
}
|
||||||
val finalValue = when (typeSpec) {
|
val finalValue = when (typeSpec) {
|
||||||
|
|||||||
Reference in New Issue
Block a user