Skip to content

Conversation

@lauzadis
Copy link
Member

@lauzadis lauzadis commented Dec 12, 2025

Issue #

Addresses #1457

Description of changes

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@lauzadis lauzadis requested a review from a team as a code owner December 12, 2025 16:51
@lauzadis lauzadis force-pushed the feat-attribute-converter branch from 5de27fa to 5a52082 Compare December 12, 2025 17:17
@lauzadis lauzadis added the no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly. label Dec 12, 2025
@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK

Comment on lines +17 to +21
/**
* Specifies the type of [ValueConverter] to be used when processing this attribute.
*/
public annotation class DynamoDbAttributeConverter(val converter: KClass<out ValueConverter<*>>)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment: I always seem to forget that annotation classes can only take KClass/Class arguments, not actual class instances. 😖 Several of the value converters (e.g., BooleanValueConverter, the various number value converters, etc.) are defined as val instances. We'll need to update those class definitions (or maybe object?) to allow users to select them in annotations. Can you either leave a FIXME somewhere and/or create a second task to handle updating the converter declarations?

Comment on lines -20 to 30
// FIXME Update to take a KClass<ItemConverter>, which will require splitting codegen modules due to a circular dependency
// FIXME Update to take a KClass<ItemConverter>?
@Target(AnnotationTarget.CLASS)
public annotation class DynamoDbItem(val converterName: String = "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment: Yes, we'll definitely still want to do this. I think that'll be far more convenient.

Comment on lines -45 to 46
val annotation = SchemaRenderer(annotated, renderCtx)
val annotation = SchemaRenderer(logger, annotated, renderCtx)
annotation.render()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Isn't the logger already available in renderCtx?

Comment on lines +10 to +19
kotlin {
sourceSets {
commonMain {
dependencies {
// For ValueConverter
implementation(project(":hll:dynamodb-mapper:dynamodb-mapper"))
}
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment: I'd hoped to keep the dependencies clean for the annotations package but we obviously need the ValueConverter (and soon, ItemConverter) types. I wonder if we should extract a dynamodb-mapper-core-api package which contains some important interfaces but no implementations.

Comment on lines +587 to +606
assertContains(
schemaContents,
""" AttributeDescriptor(
"occupation",
Employee::occupation,
Employee::occupation::set,
org.example.OccupationConverter(),
),""",
)

// Test cross-package converter
assertContains(schemaContents, "import a.different.pkg.HealthcareConverter")
assertContains(
schemaContents,
""" AttributeDescriptor(
"healthcare",
Employee::healthcare,
Employee::healthcare::set,
a.different.pkg.HealthcareConverter(),
),""",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: String indentation is a little wonky.

Comment on lines +23 to +27
@property:DynamoDbAttributeConverter(OccupationConverter::class)
var occupation: Occupation = Occupation("Student", 0),

@property:DynamoDbAttributeConverter(HealthcareConverter::class)
var healthcare: Healthcare = Healthcare(false),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Having to qualify the target in the annotation line seems kind of ugly and unintuitive. Is this still required if the annotation class is annotated with @Target(AnnotationTarget.PROPERTY)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog Indicates that a changelog entry isn't required for a pull request. Use sparingly.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants