jsonschema2pojo
jsonschema2pojo copied to clipboard
Cast parent builder to this builder return type
trafficstars
This PR adds wrapper methods to the builder class calling the withXXX builder method of the parent builder and casting the result to the class of the current builder, e.g.:
public static abstract class ChildBuilderBase<T extends Child> extends Parent.ParentBuilderBase<T> {
...
@Override
public Child.ChildBuilderBase<T> withTimestamp(Instant timestamp) {
return ((Child.ChildBuilderBase<T> ) super.withTimestamp(timestamp));
}
...
}
This allows to actually use inherited builders with a fluent API.
Fixes https://github.com/joelittlejohn/jsonschema2pojo/issues/1242
Looks like there is some problem with the way this interacts with the 'inner builder' option.
Looks like there is some problem with the way this interacts with the 'inner builder' option.
Sorry for that. I think I found a better solution that avoids this issue.