Package org.springframework.data.util
Class KotlinReflectionUtils
java.lang.Object
org.springframework.data.util.KotlinReflectionUtils
Reflection utility methods specific to Kotlin reflection. Requires Kotlin classes to be present to avoid linkage
errors.
- Since:
- 2.3
- Author:
- Mark Paluch, Christoph Strobl, Johannes Englmeier
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic kotlin.reflect.KFunction<?>
findKotlinFunction
(Method method) Returns aKFunction
instance corresponding to the given JavaMethod
instance, ornull
if this method cannot be represented by a Kotlin function.static Class<?>
getReturnType
(Method method) Returns thereturn type
of a KotlinMethod
.static boolean
isDataClass
(Class<?> type) Return true if the specified class is a Kotlin data class.static boolean
isSupportedKotlinClass
(Class<?> type) Return true if the specified class is a supported Kotlin class.static boolean
Returns whether theMethod
is declared as suspend (Kotlin Coroutine).
-
Method Details
-
isSupportedKotlinClass
Return true if the specified class is a supported Kotlin class. Currently supported are only regular Kotlin classes. Other class types (synthetic, SAM, lambdas) are not supported via reflection.- Returns:
- true if
type
is a supported Kotlin class.
-
isDataClass
Return true if the specified class is a Kotlin data class.- Returns:
- true if
type
is a Kotlin data class. - Since:
- 2.5.1
-
findKotlinFunction
Returns aKFunction
instance corresponding to the given JavaMethod
instance, ornull
if this method cannot be represented by a Kotlin function.- Parameters:
method
- the method to look up.- Returns:
- the
KFunction
ornull
if the method cannot be looked up.
-
isSuspend
Returns whether theMethod
is declared as suspend (Kotlin Coroutine).- Parameters:
method
- the method to inspect.- Returns:
- true if the method is declared as suspend.
- See Also:
-
KFunction.isSuspend()
-
getReturnType
Returns thereturn type
of a KotlinMethod
. Supports regular and suspended methods.- Parameters:
method
- the method to inspect, typically any synthetic JVMMethod
.- Returns:
- return type of the method.
-