Its some time now, but maybe it still helps. The copy-function of lombok is @With, which creates a copy with one property changed.
For your example it might be something like myModel1.withMyString("other string")
which will create a copy of myModel1 with the changed myString value.
Thats what I also like about lombok, that you can use just the parts you need. Immutable is hard to use for legacy code, since you need to adapt all at once, while lombok leaves you with the chance to enhance classes with just the stuff you need. Copy a class? Add @With to it. Want a builder? Add @Builder to a class. Get rid of existing getters and setters? Just add @Getter and/or @Setter to it and delete whats already there.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I just checked the Lombok generated code and I cannot see the utility method for copying/cloning:
Can you point me to an example or documentation around that?
Its some time now, but maybe it still helps. The copy-function of lombok is @With, which creates a copy with one property changed.
For your example it might be something like
myModel1.withMyString("other string")
which will create a copy of
myModel1
with the changedmyString
value.Thats what I also like about lombok, that you can use just the parts you need. Immutable is hard to use for legacy code, since you need to adapt all at once, while lombok leaves you with the chance to enhance classes with just the stuff you need. Copy a class? Add
@With
to it. Want a builder? Add@Builder
to a class. Get rid of existing getters and setters? Just add@Getter
and/or@Setter
to it and delete whats already there.