kotlin-builder-annotation icon indicating copy to clipboard operation
kotlin-builder-annotation copied to clipboard

Support builder generation for 3rd party types

Open manosbatsis opened this issue 5 years ago • 3 comments

It would be great if classes from dependencies could be targeted when creating builders, perhaps with an additional annotation like

@BuilderFor(SomeJavaOrKotlinBean::class.java)
class DummyPlaceholder

Some reasons for this:

  • In some cases builders are needed for 3rd party classes
  • The developer might actually control the sourcecode but other restrictions or requirements may apply. E.g. in Corda apps the state JARs where the POJOs are located needs to be as thin as possible, so other component types are preferably located in separate artefacts

I suppose i'm asking if a PR would be considered?

manosbatsis avatar Mar 31 '20 18:03 manosbatsis

HI @manosbatsis sorry for the late reply - I've not been getting notifications, despite watching the repository. Yes, I'd happily consider a PR! :)

YetAnotherMatt avatar May 04 '20 09:05 YetAnotherMatt

@YetAnotherMatt the above commit is still a WiP but feedback on my fork is welcome. The missing bits mostly relate with support for annotating "mixins" with @BuilderOf, i.e. types where property annotations like @DefaultValue can be used as if annotating a property of BuilderOf's "target" to provide the same features with @Builder.

BTW moving kapt-related helpers to a separate project might make sense. FWIW i would be more happy contributing there instead of duplicating the work e.g. like i do in https://github.com/manosbatsis/kotlin-utils/tree/master/kotlin-utils-kapt

manosbatsis avatar Jun 12 '20 19:06 manosbatsis

Hi @manosbatsis thanks for the PR and update. I'll have a look as soon as I get the chance (which may not be that soon I'm afraid)

YetAnotherMatt avatar Jun 13 '20 12:06 YetAnotherMatt