Interface Settings


public interface Settings
This class provides an API for updating settings programmatically. An instance of this class can be created using one of the static methods below. Instances of this class can be shared when creating different objects.
  • create() - returns a new instance of blank settings
  • defaults() - returns a new instance containing default settings

Out of the box, Instancio uses default settings as returned by defaults(). Defaults can be overridden either globally using a configuration file, or per-object using the API, for example:


     // Create a blank instance of settings and set the overrides
     Settings settings = Settings.create()
         .set(Keys.COLLECTION_MIN_SIZE, 50)
         .set(Keys.COLLECTION_MAX_SIZE, 100);

     // Pass the overrides when creating an object
     Person person = Instancio.of(Person.class)
         .withSettings(settings)
         .create();
 

For information on how to override settings globally using a configuration file, please refer to the user guide.

Since:
1.0.1
See Also: