Package org.instancio
Interface Model<T>
- Type Parameters:
T
- type to be created by this model
- All Known Implementing Classes:
InternalModel
public interface Model<T>
A model containing all the information for populating a class that
can be obtained using the
'toModel()'
method:
Models can be useful when class population needs to be customised and the customisations re-used in different parts of the code.
Example:
Model<Person> personModel = Instancio.of(Person.class)
.supply(field("fullName"), () -> "Jane Doe")
.generate(field("age"), gen -> gen.ints().min(18).max(65))
.toModel();
// Re-use the model to create instances of Person class
// without duplicating model's details
Person person = Instancio.create(personModel);
Since the internal data of the model is not part of the public API, this interface does not contain any methods.