From 68c2606a226e55814062377fd6138b139b100f67 Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 19 Aug 2024 21:12:32 +0200 Subject: [PATCH] Matched JsonIgnore target and retention Jackson's @JsonIgnore values; suppressed compiler warnings; fixed using it on getters --- BankingClientModel/build.gradle.kts | 2 +- .../net/codinux/banking/client/model/config/JsonIgnore.kt | 6 ++++++ .../banking/client/model/response/GetAccountDataResponse.kt | 1 + .../net/codinux/banking/client/model/tan/FlickerCode.kt | 3 ++- .../kotlin/net/codinux/banking/client/model/tan/TanImage.kt | 3 ++- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/BankingClientModel/build.gradle.kts b/BankingClientModel/build.gradle.kts index 2fa7e220..c1b6afc9 100644 --- a/BankingClientModel/build.gradle.kts +++ b/BankingClientModel/build.gradle.kts @@ -93,7 +93,7 @@ kotlin { jvmMain { dependencies { - implementation("com.fasterxml.jackson.core:jackson-annotations:2.15.0") + compileOnly("com.fasterxml.jackson.core:jackson-annotations:2.15.0") } } jvmTest { } diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/config/JsonIgnore.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/config/JsonIgnore.kt index d47ad1e8..4d46dd30 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/config/JsonIgnore.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/config/JsonIgnore.kt @@ -1,3 +1,9 @@ package net.codinux.banking.client.model.config +/** + * Annotation to be able to apply Jackson's @com.fasterxml.jackson.annotation.JsonIgnore in common module + */ +// match the target and retention settings of Jackson's JsonIgnore annotation +@Target(AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FIELD, AnnotationTarget.PROPERTY_GETTER) +@Retention(AnnotationRetention.RUNTIME) expect annotation class JsonIgnore() diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/GetAccountDataResponse.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/GetAccountDataResponse.kt index bcd084aa..3c7a26ba 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/GetAccountDataResponse.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/GetAccountDataResponse.kt @@ -5,6 +5,7 @@ import net.codinux.banking.client.model.CustomerAccount import net.codinux.banking.client.model.config.JsonIgnore import net.codinux.banking.client.model.config.NoArgConstructor +@Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED") @NoArgConstructor open class GetAccountDataResponse( val customer: CustomerAccount diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/FlickerCode.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/FlickerCode.kt index 0a21d3d1..8fb77557 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/FlickerCode.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/FlickerCode.kt @@ -3,6 +3,7 @@ package net.codinux.banking.client.model.tan import net.codinux.banking.client.model.config.JsonIgnore import net.codinux.banking.client.model.config.NoArgConstructor +@Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED") @NoArgConstructor open class FlickerCode( val challengeHHD_UC: String, @@ -10,7 +11,7 @@ open class FlickerCode( val decodingError: String? = null ) { - @JsonIgnore + @get:JsonIgnore val decodingSuccessful: Boolean get() = decodingError == null diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanImage.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanImage.kt index bc0cb512..da739a76 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanImage.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanImage.kt @@ -3,6 +3,7 @@ package net.codinux.banking.client.model.tan import net.codinux.banking.client.model.config.JsonIgnore import net.codinux.banking.client.model.config.NoArgConstructor +@Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED") @NoArgConstructor open class TanImage( val mimeType: String, @@ -10,7 +11,7 @@ open class TanImage( val decodingError: String? = null ) { - @JsonIgnore + @get:JsonIgnore val decodingSuccessful: Boolean get() = decodingError == null