[Java client] add a way to duplicate an model class
Created by: jmini
There are scenario where being able to create a new instance of a model class with the same values as an other one is necessary.
Example:
Pet pet = api.getPetById().petIdPath(id).executeAs(r -> r.thenReturn());
Pet body = pet; // this should be a new instance of Pet, a copy with the same values.
pet.setName("New name");
api.updatePet().body(body).execute(r -> r.prettyPeek());
Pet pet2 = api.getPetById().petIdPath(id).executeAs(r -> r.thenReturn());
// here you need the pet instance as it was (without any modification)
// and pet2 to perform some assertions
I suggest to add two constructors to the models classes:
- An empty one (current behaviour)
- A constructor accepting an other instance of the same class
In the second case, the values will be copied.