-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support for Compilation Time Expressions in Annotations #8954
Conversation
test failures are unrelated and related to the latest changes to the validation module |
I will review this PR tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have created several improvements PRs:
- test: add missing groovy tests #9000
- add missing kotlin test and slightly more idiomatic kotlin code for docs #8999
- imp: use class:isInstance and class:cast #8998
- use ObjectUtils::coerceToBoolean in Utils classes #8997
- test: Test ObjectUtils::coerceToBoolean #8996
It misses package-info.java
in the package and subpackages of io.micronaut.expressions
.
What’s new section does not contain anything about Expression. It would be great if you could add a link such as:
`<<evaluatedExpressions, Evaluated Expressions>>`
I think this is an exciting feature. I will create an issue in security to support something like: @Secured(condition = "#{authentication.attributes.email == '[email protected]' }
...ssor/src/main/java/io/micronaut/expressions/context/ExpressionCompilationContextFactory.java
Show resolved
Hide resolved
inject-java/src/main/java/io/micronaut/annotation/processing/visitor/JavaMethodElement.java
Outdated
Show resolved
Hide resolved
…ocs (#8999) * add missing test for Kotlin example * don't specify type * more idiomatic kotlin with assigment * don't start application
Co-authored-by: Sergio del Amo <[email protected]>
SonarCloud Quality Gate failed. |
@GavrilovSV I have merged the first cut of this. Thank you for your work implementing the basics of this feature, I think it has great potential. There are still areas of improvement that I would like to address before GA:
|
closed / merged these.
This is not public API as it is part of the processor module which is mostly internal API. However we can add this if you feel strongly about it. |
From feature request #8323 this PR implements the following set of features:
null
-
,/
,*
,%
,^
on numeric types+
on both numeric types and strings>
,<
,>=
,<=
,==
,!=
)instanceof
operator (e.g.'abc' instanceof T(java.langString)
)matches
for regex mathing (e.g.'abc' matches '^[a-z]*'
) (including/.+/
syntax for regex)empty
for checking of an object is null or empty&&
,||
,!
. We should probably also allow using aliases here (and
,or
,not
)instanceof
operationgetBean(T(io.micronaut.CustomType))
T(java.lang.Math).random()
)list[1]
)map['key']
)ages.filter(age -> age > 18)
)persons.map(p -> p.age)
)For filtering/mapping probably makes sense to support lambda syntax.
.
(e.g.object.property.nestedProperty
)object?.property.?.nestedProperty
)object.name().lenght()
)T(java.lang.Math).random()
)expr ? 'trueResult' : 'falseResult'
age?:18
, note only makes sense if we implement coercion to boolean for numbers, lists, strings etc.)new
keyword (this might be useful in@Value
annotation, e.g.@Value(#{ new io.micronaut.CustomType() })
new int[] {1, 2, 3}
) - not sure whether this is a useful one, since inlining list gives similar behavior{1, 2, 3}
syntax{ 'first': 1, 'second': 2 }
ctx[io.micronaut.CustomBean]
)env['custom.property']
)See #8323