-1

With lombok we can use AllArgumentConstructor and some other comination. Intellij also provies generator to construct with fields.

But i dont want to do something like this, specially lots of parameter

public User( User user) {
   this.id = user.getId
   ///////////////
}

Also i dont want to clone the object. I have been looking for some annotation or a way to code least.

mahfuj asif
  • 1,691
  • 1
  • 11
  • 32
  • 1
    Does this answer your question? [Build an object from an existing one using lombok](https://stackoverflow.com/questions/47069561/build-an-object-from-an-existing-one-using-lombok) – gkns Dec 29 '21 at 06:22

1 Answers1

1
public User( User user) {
   this.id = user.getId
   ///////////////
}

Isn't this exactly the copy constructor? Ref: https://www.baeldung.com/java-copy-constructor

Also see: Build an object from an existing one using lombok

gkns
  • 697
  • 2
  • 12
  • 32