Hi,
I try to make a Builder in Kotlin, all was fine with this sample code I inspirate from, but my goal is to consume it in Java (Kotlin default parameters = Overload methods), so the Builder pattern in Kotlin is not usefull to use in Java with this sample code.
what alternatives I have ?
don't help, because its generate Overload methods (like I said in my initial post), so Builder pattern bring nothing if I must pass all "options" in parameters of the builder.
m
Mike
01/17/2020, 12:51 PM
Sorry, didn't read closely enough.
Hmm. If the builder is only used in one Kotlin module, you could mark the constructor as
internal
.
Then the constructor name should be 'hidden' to Java by name mangling, so the only options would be the builder syntax. But you could still use it in Kotlin as-is.