G

GenerateCopyConstructor

JetBrains

04fa9c0c-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).

Code Editing
Downloads
36K
35 896
Rating
4.1 ★
10 ratings
Category
JetBrains Marketplace
Collected
2026-11-04
weekly snapshot

Rating distribution

4.1 ★ 10 ratings
5★ 70.0%
4★ 30.0%

Reviews 7

★★★★★ Jan Pardubicky 2020-02-12

Really helpful! Thanks a lot!

★★★★★ Daniel Stelle 2018-12-07

Very handy!

★★★★★ Ad van Erp 2018-02-24

Johann, thanks. It helps a lot.

★★★★★ William D. 2020-07-09

Helpful ! But it does not generate with generics

★★★★★ Szymon Walkowski 2015-12-14

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.

★★★★★ Michael Hibay 2015-12-17

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...

★★★★★ anonymous 2015-04-01

Copies over private static final fields as well. This is an issue.

Similar in “Code Editing”