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

Week 32: Groovy AST Transformations By Example #45

Open
shekhargulati opened this issue Aug 7, 2016 · 1 comment
Open

Week 32: Groovy AST Transformations By Example #45

shekhargulati opened this issue Aug 7, 2016 · 1 comment
Labels

Comments

@shekhargulati
Copy link
Owner

Please provide your feedback by posting a comment against this issue.

@sdp0et
Copy link

sdp0et commented Apr 19, 2017

This was from a while ago, so I'll post some code snippets to refresh your memory. I've been wrestling with a problem trying to get a Transform to utilize the default value for the annotation parameters when empty.

`import playground.Hash

    @Hash
    class Foo{
        String msg`

where in Hash:
String algorithm() default "SHA1";
the AnnotationNode will have null for .getMember("algorithm")
In ToHashAdderAstTransformation you get around this by checking for null and providing the default value again:
List<ASTNode> astNodes = new AstBuilder() .buildFromString(String.format(hashString, classNode.getName(), hashProvider != null ? hashProvider.getValue() : "SHA1"));

Is there a way to use the actual default value set in the Annotation class? What is the point of supplying it if it is not available to the Transform class? Thanks for any help you can provide.

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