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: docs-source/src/en/library/kavaref-extension.md
+10-11Lines changed: 10 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,12 +44,11 @@ Please change `<version>` to the version displayed at the top of this document.
44
44
45
45
You can view the KDoc [click here](kdoc://kavaref-extension).
46
46
47
-
### Class Extensions
47
+
### Class Extension
48
48
49
-
KavaRef provides some extensions that are more convenient when dealing with `Class` objects.
49
+
KavaRef provides convenient extensions when dealing with `Class` objects.
50
50
51
-
KavaRef also adds `KClass` extensions to the `Class` extensions,
52
-
which is used to call `KClass.java`, making it more concise than using `Some::class.java` directly.
51
+
KavaRef also brings these extensions to `KClass`, allowing you to call `KClass.java` more concisely than using `Some::class.java` directly.
53
52
54
53
#### Create Class Object
55
54
@@ -101,7 +100,7 @@ You can also use the `hasSuperclass` and `hasInterfaces` methods to determine wh
101
100
::: danger
102
101
103
102
The `Class` passed in by the `classOf` method will perform unboxing of Java wrapper classes by default,
104
-
whether you pass in something like `kotlin.Boolean` or `java.lang.Boolean` (see [Java Wrapper Classes Extensions](#java-wrapper-classes-extensions) below),
103
+
whether you pass in something like `kotlin.Boolean` or `java.lang.Boolean` (see [Java Wrapper Classes Extension](#java-wrapper-classes-extension) below),
105
104
If you need to avoid the incoming `Class` being unboxed into primitive types, you need to explicitly set the `primitiveType = false` parameter.
106
105
107
106
:::
@@ -189,7 +188,7 @@ myClassOrNull?.resolve()
189
188
otherClassOrNull?.resolve()
190
189
```
191
190
192
-
#### ClassLoader Extensions
191
+
#### ClassLoader Extension
193
192
194
193
KavaRef also provides some practical extension methods for `ClassLoader`.
195
194
@@ -204,7 +203,7 @@ val myClassOrNull = classLoader.loadClassOrNull("com.example.MyClass")
204
203
val isClassExists = classLoader.hasClass("com.example.MyClass")
205
204
```
206
205
207
-
### Array Class Extensions
206
+
### Array Class Extension
208
207
209
208
In Java, the `Class` object of an array is a special `Class` object, and usually we create it as follows.
210
209
@@ -226,7 +225,7 @@ Now, the `Class` object that creates `java.lang.String[]` can be written like th
226
225
val arrayClass =ArrayClass(String::class)
227
226
```
228
227
229
-
### Member Extensions
228
+
### Member Extension
230
229
231
230
KavaRef provides some extension methods to simplify operations on `Member`.
232
231
@@ -245,7 +244,7 @@ method.makeAccessible()
245
244
246
245
Similarly, KavaRef also extends `Modifier`, and you can directly use `Member.isPublic` and other methods to judge a `Member` modifier.
247
246
248
-
### Type Extensions
247
+
### Type Extension
249
248
250
249
When manipulating types or generic types in Java, you usually need to use the `Type` interface and its subinterface to handle it.
251
250
@@ -287,7 +286,7 @@ val myClass: Class<*>
287
286
val arguments = myClass.genericSuperclassTypeArguments()
288
287
```
289
288
290
-
### Type Reference Extensions
289
+
### Type Reference Extension
291
290
292
291
In Java, method generics are erased after compilation, and the type obtained at runtime is `java.lang.Object`.
293
292
@@ -319,7 +318,7 @@ inline fun <reified T : Any> T.toJson(): String = gson.toJson(this, typeRef<T>()
319
318
val json =listOf("KavaRef", "is", "awesome").toJson()
320
319
```
321
320
322
-
### Java Wrapper Classes Extensions
321
+
### Java Wrapper Classes Extension
323
322
324
323
In Kotlin, you can directly use `Boolean::class`, `Byte::class`, etc. to obtain Java's original types `boolean` and `byte` instead of their wrapper classes.
0 commit comments