Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Required parameters as part of builder constructor #19

Open
tobrun opened this issue Feb 27, 2022 · 1 comment
Open

Required parameters as part of builder constructor #19

tobrun opened this issue Feb 27, 2022 · 1 comment

Comments

@tobrun
Copy link
Owner

tobrun commented Feb 27, 2022

This is a feature request to add an option to the annotation to generate a builder pattern that requires its required parameters to be passed in through the builder constructor.

@DataCompat(reqParamConstructor=true)
private data class FooBarData(
  private val foo:String,
  private val fooOptional:String?
  private val fooDefault:String = "bar"
)

This will result in:

Foo("foo"){
   fooOptional = "optional"
   fooDefault = "bar2"
}

or on the java side:

FooBar.Builder("foo")
   .setFooOptional("optional")
   .setFooDefault("bar2")

cc @LukasPaczos

@RingerJK
Copy link

fooDefault is provided by default so

Foo("foo"){
   fooOptional = "optional"
}

and

FooBar.Builder("foo")
   .setFooOptional("optional")

should work and fooDefault is assign under the hood to "bar"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants