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

Closed
enedzvetsky opened this issue Feb 21, 2019 · 2 comments
Closed

Support custom ObjectFactory #341

enedzvetsky opened this issue Feb 21, 2019 · 2 comments
Labels
Milestone

Comments

@enedzvetsky
Copy link

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.
@fmbenhassine
Copy link
Member

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.

@fmbenhassine fmbenhassine added this to the 4.0.0 milestone Feb 22, 2019
@fmbenhassine
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants