kubernetes-client icon indicating copy to clipboard operation
kubernetes-client copied to clipboard

Model has lombok.Setter when is not needed

Open jorsol opened this issue 1 year ago • 3 comments

Describe the bug

Almost all the models are annotated with @Setter but the setters seem to be explicitly generated.

Fabric8 Kubernetes Client version

SNAPSHOT

Steps to reproduce

https://github.com/fabric8io/kubernetes-client/blob/409be3b32de4f0f7d74d99186b4df98c042d0132/kubernetes-model-generator/kubernetes-model-core/src/generated/java/io/fabric8/kubernetes/api/model/Pod.java#L36

Expected behavior

The annotation should not be present when the setter is already generated:

https://github.com/fabric8io/kubernetes-client/blob/409be3b32de4f0f7d74d99186b4df98c042d0132/kubernetes-model-generator/kubernetes-model-core/src/generated/java/io/fabric8/kubernetes/api/model/Pod.java#L106

Runtime

other (please specify in additional context)

Kubernetes API Server version

1.25.3@latest

Environment

other (please specify in additional context)

Fabric8 Kubernetes Client Logs

No response

Additional context

This seems to be harmless and Lombok does not generate the setters if found one, but having one less annotation that does magical stuff is better.

jorsol avatar Jul 02 '24 11:07 jorsol

Added in fix for #3570 in #3576 PR.

It's used to create the setAdditionalProperties method which is not included in the generated code by default.

We can do specific handling and add the additionalProperties setter ourselves using a custom rule.

manusa avatar Jul 02 '24 13:07 manusa

Well, if it's used to create the setAdditionalProperties then is ok to have it, yet it would be better to add the setter using a custom rule like you mention.

Honestly, if the toString, equals and hashCode can be also generated to remove lombok completely, that would be nice.

jorsol avatar Jul 02 '24 14:07 jorsol

Well, if it's used to create the setAdditionalProperties then is ok to have it, yet it would be better to add the setter using a custom rule like you mention.

I opened #6102 to address this

Honestly, if the toString, equals and hashCode can be also generated to remove lombok completely, that would be nice.

I'm working on a replacement generator (#6080) to completely remove the Go-to-JSONSchema and the JSONSchema-to-Java code generation steps. Once this is in place, it will be really easy to modify the templates so that the code is generated without Lombok annotations or anything else we want to change.

manusa avatar Jul 02 '24 14:07 manusa