Last active
January 15, 2021 01:09
-
-
Save shomah4a/a3fb769d4db142a66190b0f1af3b46b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SomeTest() { | |
data class Hoge( | |
@get:Min(10) | |
val x: Int | |
) | |
@Validated | |
@Component | |
class Fuga() { | |
fun tt(@Valid hoge: Hoge) { | |
println(hoge) | |
} | |
} | |
@Test | |
fun hoge() { | |
val proxy = AopProxyUtil.proxy(Fuga()) | |
proxy.tt(Hoge(1)) | |
} | |
} | |
object AopProxyUtil { | |
@Suppress("UNCHECKED_CAST") | |
fun <T: Any> proxy(target: T): T { | |
val factory = ProxyFactory(target) | |
factory.addAdvice(MethodValidationInterceptor()) | |
return factory.proxy as T | |
} | |
} |
Author
shomah4a
commented
Jan 15, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment