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

[Feature] user custom instantiators #243

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

frecco75
Copy link
Collaborator

@frecco75 frecco75 commented Mar 24, 2020

The idea of this feature is to provide a mechanism for users to define custom instantiators like it exists for custom field value changers. It follows the same idea to let user extends pojo-tester mechanism.

It already exists a mechanism that let the user to select the choosen constructor (explanations here) but it is not efficient when the pojo use provided types from external libraries.

Here are the steps to add pojo tester support for an external librairy types (for example vavr) in an external project :

  1. Step 1 : define instantiator for custom types (vavr types for example). You have to inherits the UserObjectInstantiator class
  2. Step 2 : attach the custom instantiator :
    Instantiator.INSTANCE.attach(VavrTypesInstantiator.class);

Now we can use pojo tester with an object using vavr types, for example :

class User {
    private int id;
    private Option<String> email;  // Option is a Vavr type
}

Detailed example here with vavr collections.

@frecco75 frecco75 changed the title [Feature] custom instantiators [Feature] user custom instantiators Mar 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant