Skip to content

Add property factory support for data classes#41

Merged
MessiasLima merged 4 commits into
mainfrom
feat/property-factory-support-14335845514827790920
May 18, 2026
Merged

Add property factory support for data classes#41
MessiasLima merged 4 commits into
mainfrom
feat/property-factory-support-14335845514827790920

Conversation

@MessiasLima
Copy link
Copy Markdown
Owner

This change introduces support for per-property overrides in data classes.
Previously, users had to provide all constructor arguments when using a custom factory for a data class.
With this update, users can use property(MyClass::myProp) { value } to override only specific properties, while the library auto-generates the rest.

Key changes:

  • SomeConfigBuilder.property(KProperty1<T, V>, FixtureContext.() -> V) registers an override.
  • DataClassResolver now receives the map of property factories and applies them during the resolve process.
  • Integration tests cover various scenarios including precedence, multiple overrides, and optional parameters.

Fixes #39


PR created automatically by Jules for task 14335845514827790920 started by @MessiasLima

- Added `property()` method to `SomeConfigBuilder` for per-property overrides using `KProperty1`.
- Updated `SomeConfig` to store and propagate property factories.
- Integrated property factory resolution into `DataClassResolver`.
- Added comprehensive integration tests in `PropertyFactoryIntegrationTest`.
- Ensured type factories take precedence over property factories.
- Added support for overriding optional parameters while preserving other defaults.

Co-authored-by: MessiasLima <[email protected]>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the ability to register custom factory functions for specific properties within a data class, enhancing the flexibility of the fixture generation. Key changes include the addition of a propertyFactories map to the configuration, a new property method in the configuration builder, and updates to the DataClassResolver to utilize these factories during object instantiation. Feedback focuses on improving the DSL's robustness and performance by using reified type parameters to avoid reflection and hoisting the FixtureContext creation within the resolver to reduce redundant allocations.

Comment thread src/main/kotlin/dev/appoutlet/some/config/SomeConfigBuilder.kt
Comment thread src/main/kotlin/dev/appoutlet/some/resolver/DataClassResolver.kt
@MessiasLima MessiasLima merged commit a49bde6 into main May 18, 2026
1 check passed
@MessiasLima MessiasLima deleted the feat/property-factory-support-14335845514827790920 branch May 18, 2026 18:56
@github-project-automation github-project-automation Bot moved this from Ready to Done in Some May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add property factory support for per-property overrides on data classes

1 participant