Skip to content

Commit 9ef95d7

Browse files
committed
style: update demo
1 parent 3acdee6 commit 9ef95d7

File tree

1 file changed

+8
-0
lines changed
  • samples/kavaref-demo/src/main/kotlin/com/highcapable/kavaref/demo

1 file changed

+8
-0
lines changed

samples/kavaref-demo/src/main/kotlin/com/highcapable/kavaref/demo/Main.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,51 +30,59 @@ import com.highcapable.kavaref.runtime.KavaRefRuntime
3030
fun 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)

0 commit comments

Comments
 (0)