-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extend PropertyUtils to support multiple json serialization libraries
- Loading branch information
Jens Zettelmeyer
committed
Oct 29, 2023
1 parent
4dff08a
commit 5d84940
Showing
3 changed files
with
70 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.cjbooms.fabrikt.model | ||
|
||
import com.squareup.kotlinpoet.FunSpec | ||
import com.squareup.kotlinpoet.PropertySpec | ||
|
||
sealed interface Annotations { | ||
fun addIgnore(property: PropertySpec.Builder) | ||
|
||
fun addGetter(`fun`: FunSpec.Builder): FunSpec.Builder | ||
|
||
fun addSetter(`fun`: FunSpec.Builder): FunSpec.Builder | ||
|
||
fun addProperty(property: PropertySpec.Builder, oasKey: String): PropertySpec.Builder | ||
|
||
fun addParameter(property: PropertySpec.Builder, oasKey: String): PropertySpec.Builder | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/kotlin/com/cjbooms/fabrikt/model/JacksonAnnotations.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.cjbooms.fabrikt.model | ||
|
||
import com.cjbooms.fabrikt.generators.model.JacksonMetadata | ||
import com.squareup.kotlinpoet.FunSpec | ||
import com.squareup.kotlinpoet.PropertySpec | ||
|
||
object JacksonAnnotations : Annotations { | ||
override fun addIgnore(property: PropertySpec.Builder) { | ||
property.addAnnotation(JacksonMetadata.ignore) | ||
} | ||
|
||
override fun addGetter(`fun`: FunSpec.Builder): FunSpec.Builder { | ||
return `fun`.addAnnotation(JacksonMetadata.anyGetter) | ||
} | ||
|
||
override fun addSetter(`fun`: FunSpec.Builder): FunSpec.Builder { | ||
return `fun`.addAnnotation(JacksonMetadata.anySetter) | ||
} | ||
|
||
override fun addProperty(property: PropertySpec.Builder, oasKey: String): PropertySpec.Builder { | ||
return property.addAnnotation(JacksonMetadata.jacksonPropertyAnnotation(oasKey)) | ||
} | ||
|
||
override fun addParameter( | ||
property: PropertySpec.Builder, | ||
oasKey: String | ||
): PropertySpec.Builder { | ||
return property.addAnnotation(JacksonMetadata.jacksonParameterAnnotation(oasKey)) | ||
} | ||
} |