-
Notifications
You must be signed in to change notification settings - Fork 122
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
Is there a reason @Produced is not allowed for Target=TYPE_USE? #235
Comments
@vlsi Thanks for this. I guess I hadn't imagined that programmers would use public class GeneratorDescriptors {
public static final HashMap<
@From(value = KnownManifestKeyGenerator.class, frequency = 50),
@From(value = RegexStringGenerator.class, frequency = 50)
String,
String> manifestAttributes = null;
} If you believe it's important enough to allow Thanks also for diving deeply into junit-quickcheck! I'm always excited to hear of opportunities for improvement. |
@visi In fact, if you're interested, I could use some extra eyes on #173. Meta-annotation support would allow you to craft a meta-annotation marked with the public static final HashMap<@ManifestKeyHalfAndHalf String, String> manifestAttributes = null;
} |
@pholser , I've tried a bit more. Meta-annotation helps, however public class GeneratorDescriptors {
@From(value = KnownManifestKeyGenerator.class, frequency = 10)
@Regex("[-_a-zA-Z0-9]")
@From(value = RegexStringGenerator.class, frequency = 90)
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE_USE)
@GeneratorConfiguration
@interface ManifestKey {
}
public static final HashMap<@ManifestKey String, String> manifestAttributes = null;
} @Target([PARAMETER, FIELD, ANNOTATION_TYPE, TYPE_USE])
@Retention(RetentionPolicy.RUNTIME)
@GeneratorConfiguration
public @interface Regex {
String value()
} class RegexStringGenerator extends AbstractStringGenerator {
private Generex generex
private InRange range
private Size size
public void configure(Regex regex) {
this.generex = new Generex(regex.value())
}
public void configure(InRange range) {
this.range = range
}
public void configure(Size size) {
this.size = size
}
@Override
String generate(SourceOfRandomness random, GenerationStatus status) {
if (generex == null) {
throw new IllegalArgumentException("@Regex was not specified for RegexStringGenerator")
}
generex.setSeed(random.nextLong())
return generex.random()
}
@Override
protected int nextCodePoint(SourceOfRandomness random) {
return 0
}
@Override
protected boolean codePointInRange(int codePoint) {
return true
}
} |
On top of that, I wonder how could I configure multiple |
@pholser the error is the same for multi-from as well: public static final HashMap<
@From(value = StringGenerator.class)
@From(value = StringGenerator.class) String,
String> manifestAttributes2 = null;
|
@visi Ah ok, thanks. I'll investigate. Sounds like we'd need to make the change regardless. |
Yes. TYPE_USE for |
For #235, add TYPE_USE to Produced's Retention
@vlsi This is on 0.9 branch right now. I'll merge to master once you're satisfied this behaves as desired. |
@pholser , id is not clear what is the suggested way to test 0.9 branch. I don't like to "install random dependencies" to the local maven repository. |
The change seems to be trivial, and it should work. |
Absolutely. I've added test class |
I will cut a 0.9.1 soon with this change in it. |
Use case:
Unfortunately,
@Produced
is not allowed forTYPE_USE
, so I can't add the annotation like that.The text was updated successfully, but these errors were encountered: