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

Allow to set an annotation parameter value as an expression #10734

Open
dstepanov opened this issue Apr 18, 2024 · 0 comments
Open

Allow to set an annotation parameter value as an expression #10734

dstepanov opened this issue Apr 18, 2024 · 0 comments
Labels
type: improvement A minor improvement to an existing feature

Comments

@dstepanov
Copy link
Contributor

Feature description

Right now, I need to do this in Micronaut Data micronaut-projects/micronaut-data#2876:

                        String originatingClassName = DataMethodQueryParameter.class.getName();
                        String packageName = NameUtils.getPackageName(originatingClassName);
                        String simpleClassName = NameUtils.getSimpleName(originatingClassName);
                        String exprClassName = "%s.$%s%s".formatted(packageName, simpleClassName, EvaluatedExpressionReferenceCounter.EXPR_SUFFIX);

                        Integer expressionIndex = EvaluatedExpressionReferenceCounter.nextIndex(exprClassName);

                        builder.members(Map.of(
                            DataMethodQueryParameter.META_MEMBER_VALUE,
                            new EvaluatedExpressionReference(expression, originatingClassName, DataMethodQueryParameter.META_MEMBER_VALUE, exprClassName + expressionIndex)
                        ));

We should consider exposing an expression with some non-internal class like AnnotationClassValue instead of the internal EvaluatedExpressionReference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: improvement A minor improvement to an existing feature
Projects
Status: No status
Development

No branches or pull requests

2 participants