Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom ObjectFactory #341

enedzvetsky opened this issue Feb 21, 2019 · 2 comments


2 participants
Copy link

commented Feb 21, 2019

We use custom class instantiators in our project. So some our project classes don't have a default constructor and these objects can be created only from these instantiators.
I would like to override method io.github.benas.randombeans.ObjectFactory#createNewInstance and inject our custom instantiators.

  1. Unfortunately, class ObjectFactory is not public
  2. EnhancedRandomBuilder doesn't have ObjectFactory customization.

This comment has been minimized.

Copy link

commented Feb 22, 2019

This is one of the things I wanted to do in a major release: making every behaviour overridable instead of configurable. See my comment here.

@benas benas added this to the 4.0.0 milestone Feb 22, 2019

@benas benas added the feature label Mar 14, 2019


This comment has been minimized.

Copy link

commented Mar 14, 2019

A new interface org.jeasy.random.api.ObjectFactory has been added in order to allow you customize object creation. It can be used as follows:

EasyRandomParameters parameters = new EasyRandomParameters()
        .objectFactory(new MyObjectFactory());

EasyRandom easyRandom = new EasyRandom(parameters);

You can find an example here and try it with version 4.0.0.RC1. Please note that the project has been renamed to Easy Random. Hence, the groupId and artifactId have changed. I invite you to check the release note which contains a migration guide.

I'm closing this issue for now, but please do not hesitate to provide your feedback by adding a comment here.

@benas benas closed this Mar 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.