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

Globally configure generator #228

Open
Allsimon opened this issue Apr 5, 2019 · 3 comments
Open

Globally configure generator #228

Allsimon opened this issue Apr 5, 2019 · 3 comments
Labels

Comments

@Allsimon
Copy link

Allsimon commented Apr 5, 2019

I'm looking for a way to globally configure a generator.

For example, I want every LocalDateTime in every POJO to be between 2000/2100.

Is it possible without rewriting every generators for those POJO ?

@pholser
Copy link
Owner

pholser commented Apr 5, 2019

@Allsimon Thanks for bringing this up. Currently there is no such feature. Generators are configured for each use via some set of configuration annotations they support. For example, the LocalDateTimeGenerator can accept an @InRange marker to specify an interval. I'm hoping to make this a little less cumbersome by allowing them to be collected on a meta-annotation, if I can find time to get to #173.

I think what you're asking for is very useful. Do you have a particular strategy in mind?

@Allsimon
Copy link
Author

Allsimon commented Apr 8, 2019

What kind of API are you planning to implement with #173 ?

I was thinking about GeneratorConfiguration chaining, something looking like this:

@From(MoneyGenerator.class)
@Children(class = Integer.class, configuration = Positive.class)
@Children(class = Double.class, configuration = CustomConf.class)
public @interface SmallChange {
}

@pholser
Copy link
Owner

pholser commented Apr 16, 2019

@Allsimon My intent behind #173 is to be able to find @Property as a meta-annotation and/or on enclosing elements, such as a class, package, or module (to allow for configuration at greater scope than individual property methods); and to find configuration annotations for a parameter as meta-annotations deeper than one level. I don't anticipate changing how programmers write tests with this change. Does that help?

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