This repository was archived by the owner on Jan 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
src/main/kotlin/com/mapk/fastkfunction Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package com.mapk.fastkfunction
3
3
import java.lang.reflect.Method
4
4
import kotlin.reflect.KClass
5
5
import kotlin.reflect.KParameter
6
+ import kotlin.reflect.full.isSuperclassOf
6
7
7
8
/* *
8
9
* Get object instance if receiver declared in object.
@@ -21,6 +22,20 @@ internal val Method.declaringObject: Any? get() = declaringClass.kotlin.objectIn
21
22
*/
22
23
internal val KParameter .clazz: KClass <* > get() = this .type.classifier as KClass <* >
23
24
25
+ /* *
26
+ * Check instance class is valid.
27
+ *
28
+ * @param expected Required clazz.
29
+ * @param actual Actual clazz.
30
+ * @throws IllegalArgumentException If actual is not required class.
31
+ */
32
+ internal fun checkInstanceClass (expected : KClass <* >, actual : KClass <* >) {
33
+ if (! expected.isSuperclassOf(actual))
34
+ throw IllegalArgumentException (
35
+ " INSTANCE parameter required ${expected.simpleName} , but ${actual.simpleName} is present."
36
+ )
37
+ }
38
+
24
39
/* *
25
40
* Throw IllegalArgumentException if instance is null.
26
41
*
You can’t perform that action at this time.
0 commit comments