Skip to content

Commit

Permalink
🎨 simplify attribute EnhancedType inference logic
Browse files Browse the repository at this point in the history
  • Loading branch information
oharaandrew314 committed Mar 1, 2024
1 parent f6c4a01 commit 4f18298
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ internal fun <Table: Any, Attr: Any?> KProperty1<Table, Attr>.toImmutableDataCla
dataClass: KClass<Table>,
schemaCache: MetaTableSchemaCache
): ImmutableAttribute<Table, ImmutableDataClassBuilder, Attr> {
val customConverter = findAnnotation<DynamoKtConverted>()
val converter = findAnnotation<DynamoKtConverted>()
?.converter
?.let { it as KClass<AttributeConverter<Attr>> }
?.let { initConverter(it) }
val converter = customConverter ?: AttributeConverterProvider.defaultProvider().converterFor(returnType.toEnhancedType(schemaCache))
?: AttributeConverterProvider.defaultProvider().converterFor(returnType.toEnhancedType(schemaCache))

val dynamoName = findAnnotation<DynamoKtAttribute>()?.name?: name

return ImmutableAttribute
.builder(
EnhancedType.of(dataClass.java),
EnhancedType.of(ImmutableDataClassBuilder::class.java),
customConverter?.type() ?: returnType.toEnhancedType(schemaCache) as EnhancedType<Attr>
converter.type() as EnhancedType<Attr>
)
.name(dynamoName)
.getter(::get)
Expand Down

0 comments on commit 4f18298

Please sign in to comment.