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 - ensure to guard usage with 
KotlinDetector.isKotlinPresent().- Since:
- 2.3
- Author:
- Mark Paluch, Christoph Strobl, Johannes Englmeier
- See Also:
- 
Method SummaryModifier and TypeMethodDescriptionstatic @Nullable kotlin.reflect.KFunction<?>findKotlinFunction(Method method) Returns aKFunctioninstance corresponding to the given JavaMethodinstance, ornullif this method cannot be represented by a Kotlin function.static Class<?>getReturnType(Method method) Returns thereturn typeof a KotlinMethod.static booleanhasValueClassProperty(Class<?> type) Returns whether the given class makes uses Kotlinvalueclasses.static booleanisDataClass(Class<?> type) Return true if the specified class is a Kotlin data class.static booleanisSupportedKotlinClass(Class<?> type) Return true if the specified class is a supported Kotlin class.static booleanReturns whether theMethodis declared as suspend (Kotlin Coroutine).static booleanisValueClass(kotlin.reflect.KType type) Returns whether the givenKTypeis avalueclass.
- 
Method Details- 
isSupportedKotlinClassReturn 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 typeis a supported Kotlin class.
 
- 
isDataClassReturn true if the specified class is a Kotlin data class.- Returns:
- true if typeis a Kotlin data class.
- Since:
- 2.5.1
 
- 
findKotlinFunctionReturns aKFunctioninstance corresponding to the given JavaMethodinstance, ornullif this method cannot be represented by a Kotlin function.- Parameters:
- method- the method to look up.
- Returns:
- the KFunctionornullif the method cannot be looked up.
 
- 
isSuspendReturns whether theMethodis declared as suspend (Kotlin Coroutine).- Parameters:
- method- the method to inspect.
- Returns:
- true if the method is declared as suspend.
- See Also:
- 
- KFunction.isSuspend()
 
 
- 
getReturnTypeReturns thereturn typeof a KotlinMethod. Supports regular and suspended methods.- Parameters:
- method- the method to inspect, typically any synthetic JVM- Method.
- Returns:
- return type of the method.
 
- 
isValueClasspublic static boolean isValueClass(kotlin.reflect.KType type) Returns whether the givenKTypeis avalueclass.- Parameters:
- type- the kotlin type to inspect.
- Returns:
- truethe type is a value class.
- Since:
- 3.2
 
- 
hasValueClassPropertyReturns whether the given class makes uses Kotlinvalueclasses.- Parameters:
- type- the kotlin type to inspect.
- Returns:
- truewhen at least one property uses Kotlin value classes.
- Since:
- 3.2
 
 
-