Open NikkyAI opened 1 year ago
Looks interesting, I have definitely encountered this. On my list to review for inclusion
If we wait long enough this will likely be solved by Kotlin itself, synthetic java accessors are scheduled for kotlin 2.1: https://youtrack.jetbrains.com/issue/KT-8575/Support-Java-synthetic-property-references. It's currently available behind a language version feature flag, although I don't know the right incantation for 1.9 or 2.0.
Still, allowing constraints to be specified for any function/lambda seems a good feature to have in general, if only because I find it annoying to not be able to easily specify constraints on nested things. Supporting KFunction
in addition to KProperty
also makes a lot of sense.
Fixes #14
yep, I think this works for us
This issue you may find interesting 🙂 Having options for Kotlin pre-2.1 would be great though! https://youtrack.jetbrains.com/issue/KT-8575/Support-Java-synthetic-property-references
may be a partial duplicate of #63 but have this code anyhow.. maybe it helps even a little bit
this allows validations of java libraries without needing to write a
val ThatClass.someValue = getSomeValue()
extensions for each propertyit also allows to use
aliased
custom accessorsa example out of our codebase using this to validate
com.nimbusds.jwt.SignedJWT
i added tests
functionAccessorSyntax
,lambdaAccessorSyntax
,complexLambdaAccessors
to demonstrate usage of this syntax