Skip to content

Commit 424d492

Browse files
committed
Update sample
1 parent e35f941 commit 424d492

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Samples/JavaKitSampleApp/Sources/JavaKitExample/JavaKitExample.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ extension HelloSwift: HelloSwiftNativeMethods {
7777
}
7878

7979
// Make sure that the thread safe class is sendable
80-
let threadSafe: Sendable = ThreadSafeHelperClass(environment: javaEnvironment)
80+
let helper = ThreadSafeHelperClass(environment: javaEnvironment)
81+
let threadSafe: Sendable = helper
82+
83+
let text: String? = helper.textOptional
84+
let value: String? = helper.getValueOptional(Optional<String>.none)
85+
let textFunc: String? = helper.getTextOptional()
8186

8287
return i * j
8388
}

Samples/JavaKitSampleApp/Sources/JavaKitExample/com/example/swift/ThreadSafeHelperClass.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,19 @@
1414

1515
package com.example.swift;
1616

17+
import java.util.Optional;
18+
1719
@ThreadSafe
1820
public class ThreadSafeHelperClass {
1921
public ThreadSafeHelperClass() { }
22+
23+
public Optional<String> text = Optional.of("");
24+
25+
public String getValue(Optional<String> name) {
26+
return name.orElse("");
27+
}
28+
29+
public Optional<String> getText() {
30+
return text;
31+
}
2032
}

0 commit comments

Comments
 (0)