![JAR search and dependency download from the Maven repository](/logo.png)
com.fintecsystems.xs2a.java.helper.BooleanAdapter.kt Maven / Gradle / Ivy
The newest version!
package com.fintecsystems.xs2a.java.helper
import com.squareup.moshi.FromJson
import com.squareup.moshi.JsonQualifier
@Retention(AnnotationRetention.RUNTIME)
@JsonQualifier
annotation class NullableBoolean
object BooleanAdapter {
@FromJson
fun fromJson(fieldToParse: Any): Boolean = when (fieldToParse) {
is String -> fieldToParse.toBooleanStrictOrNull() ?: (fieldToParse.toInt() == 1)
is Boolean -> fieldToParse
is Int -> fieldToParse == 1
else -> false
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy