GenerateCopyConstructor
JetBrains04fa9c0c-eb67-41f9-bc34-c5aadf9847e6 · v—
Adds an option to generate a copy constructor to the generate menu (alt + ins). The action will generate a copy constructor taking an instance of the same class and copying over every field. If there is a copy constructor available in the superclass it will be called as well. Also adds a number of inspections that generate warnings if a copy constructor might be faulty (e.g. not all fields copied or superclass constructor not invoked).
Rating distribution
Reviews 7
Really helpful! Thanks a lot!
Very handy!
Johann, thanks. It helps a lot.
Helpful ! But it does not generate with generics
Great, but give false "Suspicioud assingment" warnings (which I'd like to turn off in some settings [not by annotations]), for lists or using new Constructor(other.objectToCloneByConstructor). Great works with immutables strings, integers etc. But poorly with other elements/collections (need some polishing), but saved me some time anyway. Thanks.
Johann, any reason why you decided to approach this problem using direct attribute access instead of getters and setters? Getters and setters would better apply to a deep copy scenario, as well as be better protected for use as DAO's and EJB. I am nearly finished implementing something similar for a single class inspection using groovy for live templates, but it would probably serve you better...
Copies over private static final fields as well. This is an issue.
Similar in “Code Editing”
Rainbow Brackets
izhangzhihao
Full Line Code Completion
JetBrains
Package Checker
JetBrains
Amazon Q
AWS
OpenAPI Specifications
JetBrains
Makefile Language
JetBrains