You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/JavApi/JavApi⁴Swift.docc/Java2Swift.md
+33Lines changed: 33 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -196,6 +196,22 @@ The translation has a Optional problem because Java reference types are implicit
196
196
197
197
Default methods are implemented in a extension, because the mapping of Java interfaces in a Java package like structures need a bit more code.
198
198
199
+
##### toString() method
200
+
201
+
If special toString() implemetation is in Java, first let your Swift type be conform to the *CustomStringConvertible*. Next implement the property *description*. For example
202
+
203
+
```swift
204
+
publicfunctoString () ->String {
205
+
return"My name is Bond, James Bond"
206
+
}
207
+
208
+
publicvar description: String {
209
+
get {
210
+
returnself.toString()
211
+
}
212
+
}
213
+
```
214
+
199
215
#### nested classes
200
216
201
217
Nested classes in Swift can not access to enclosing type variables. Give the nested class the needed variables as (weak) parameters.
@@ -270,6 +286,23 @@ Swiftify is a JavApi extension. It make additional implementations of Java metho
270
286
271
287
Java cases `fallthrough` by default and need explicite `break` if not. But Java need no `default`. Also newer Java can use `->` instead of `:`.
272
288
289
+
If you use enum values in switch, you need a dot before the value name in case.
0 commit comments