Skip to content
Discussion options

You must be logged in to vote

This one is bit hidden. The supported way to access Settings is through InstancioServiceProvider.init(ServiceProviderContext) method. The ServiceProviderContext interface exposes getSettings() (and random() if you need it for generating reproducible data).

public class MyServiceProvider implements InstancioServiceProvider {

    private Settings settings;

    @Override
    public void init(ServiceProviderContext context) {
        this.settings = context.getSettings();
    }

    @Override
    public GeneratorProvider getGeneratorProvider() {
        return (node, generators) -> {
            // settings.get(...)
        };
    }
}

The init() method is called once getGeneratorProvider()

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nstdio
Comment options

Answer selected by nstdio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants