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

Is there a way to configure per-From GeneratorParameters? #237

Open
vlsi opened this issue Sep 17, 2019 · 0 comments
Open

Is there a way to configure per-From GeneratorParameters? #237

vlsi opened this issue Sep 17, 2019 · 0 comments
Labels

Comments

@vlsi
Copy link
Contributor

vlsi commented Sep 17, 2019

Consider a case when multiple @From are used:

public class GeneratorDescriptors {
    @From(value = KnownManifestKeyGenerator.class, frequency = 10)
    @Regex("[-_a-zA-Z0-9]+")
    @From(value = RegexStringGenerator.class, frequency = 40)
    @Retention(RetentionPolicy.RUNTIME)
    @Target(ElementType.TYPE_USE)
    @interface ManifestKey {
    }

    public final HashMap<@ManifestKey String, String> manifestAttributes = null;
}

So far so good.

However what if I would like to put two @From(value = RegexStringGenerator.class, frequency = 40) instances?
Then it would be kind of problematic to assign two @RegExp instances.
The same goes for "two @Size" case and so on. How quickcheck would know which regexp configures which generator?

In case you wondered, meta-meta does not help:

public class GeneratorDescriptors {
    @Regex("[a-z]+")
    @From(value = RegexStringGenerator.class, frequency = 90)
    @Retention(RetentionPolicy.RUNTIME)
    @Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE_USE})
    @interface RegExp1 {
    }

    @Regex("[A-Z]+")
    @From(value = RegexStringGenerator.class, frequency = 40)
    @Retention(RetentionPolicy.RUNTIME)
    @Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE_USE})
    @interface RegExp2 {
    }

    @RegExp1
    @RegExp2
    @Retention(RetentionPolicy.RUNTIME)
    @Target(ElementType.TYPE_USE)
    @interface ManifestKey {
    }

    public final HashMap<@ManifestKey String, @RegExp1 String> manifestAttributes = null;
}

I'm not sure "annotation programming" is the way to go here, however it would be really nice if something could be made around that case.

It would probably make sense if "the closest" Regex annotation was resolved for each generator.

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