File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
samples/kavaref-demo/src/main/kotlin/com/highcapable/kavaref/demo Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -30,51 +30,59 @@ import com.highcapable.kavaref.runtime.KavaRefRuntime
3030fun main () {
3131 // Enable KavaRef debug level logging.
3232 KavaRef .logLevel = KavaRefRuntime .LogLevel .DEBUG
33+
3334 // Resolve the Test class using KavaRef.
3435 // Create an instance of the Test class using the resolved class.
3536 val test = Test ::class .resolve()
3637 .firstConstructor {
3738 emptyParameters()
3839 }.create()
40+
3941 // Invoke a method, modify a field, and retrieve a value using the resolved class.
4042 // (1) Call from Class.
4143 Test ::class .resolve()
4244 .firstMethod {
4345 name = " test"
4446 parameters(String ::class )
4547 }.of(test).invoke(" reflection test" )
48+
4649 // (2) Call from Object.
4750 test.asResolver()
4851 .firstMethod {
4952 name = " test"
5053 parameters(String ::class )
5154 }.invoke(" reflection test" )
55+
5256 // Modify the field 'myTest' and retrieve its value using the resolved class.
5357 // (1) Call from Class.
5458 Test ::class .resolve()
5559 .firstField {
5660 name = " myTest"
5761 type = String ::class
5862 }.of(test).set(" Hello modified reflection test" )
63+
5964 // (2) Call from Object.
6065 test.asResolver()
6166 .firstField {
6267 name = " myTest"
6368 type = String ::class
6469 }.set(" Hello modified reflection test" )
70+
6571 // Retrieve the value of the field 'myTest' using the resolved class.
6672 // (1) Call from Class.
6773 val testString1 = Test ::class .resolve()
6874 .firstMethod {
6975 name = " getTest"
7076 emptyParameters()
7177 }.of(test).invoke<String >()
78+
7279 // (2) Call from Object.
7380 val testString2 = test.asResolver()
7481 .firstMethod {
7582 name = " getTest"
7683 emptyParameters()
7784 }.invoke<String >()
85+
7886 // Print the value of the field 'myTest'.
7987 println (testString1)
8088 println (testString2)
You can’t perform that action at this time.
0 commit comments