Consider a generator like this:
@MyAnnotation(value = "Some default")
class MyClassGenerator extends Generator<MyClass> {
private MyAnnotation myAnnotation;
...
public MyClass generate(SourceOfRandomness random, GenerationStatus status) {
MyClassFieldGenerator myClassFieldGenerator = gen().make(MyClassFieldGenerator.class);
myClassFieldGenerator.configure(myAnnotation);
return new MyClass(myClassFieldGenerator.generate(random, status))
}
public void configure(MyAnnotation myAnnotation) {
this.myAnnotation = myAnnotation;
}
}
What's interesting about it is that by calling gen().make(MyClassFieldGenerator.class) I can put my configuration annotation on generator class itself to configure defaults on it without calling to myClassFieldGenerator.configure(myAnnotation); explicitly.
But I can't do the same for Generator that is referred from a Property method itself:
@Property
public void myProperty(@From(MyClassGenerator.class) MyClass myClass) {
// here MyClassGenerator will not receive defaults from annotation present on Generator class.
}
In practice, this means that I have to instantiate default annotation instance myself if it's not provided by the framework which looks like something that could be easily avoided.
Consider a generator like this:
What's interesting about it is that by calling
gen().make(MyClassFieldGenerator.class)I can put my configuration annotation on generator class itself to configure defaults on it without calling tomyClassFieldGenerator.configure(myAnnotation);explicitly.But I can't do the same for Generator that is referred from a Property method itself:
In practice, this means that I have to instantiate default annotation instance myself if it's not provided by the framework which looks like something that could be easily avoided.