/** * Return {@literal 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. * * @return {@literal true} if {@code type} is a supported Kotlin class. * @since 2.0 */ public static boolean isSupportedKotlinClass(Class<?> type) { if (!isKotlinClass(type)) { return false; } return Arrays.stream(type.getDeclaredAnnotations()) // .filter(annotation -> annotation.annotationType().getName().equals("kotlin.Metadata")) // .map(annotation -> AnnotationUtils.getValue(annotation, "k")) // .anyMatch(it -> Integer.valueOf(KOTLIN_KIND_CLASS).equals(it)); }
/** * Check whether the owning type of {@link PersistentProperty} declares a {@literal copy} method or {@literal copy} * method with parameter defaulting. * * @param type must not be {@literal null}. * @return */ private static boolean hasKotlinCopyMethod(PersistentProperty<?> property) { Class<?> type = property.getOwner().getType(); if (isAccessible(type) && org.springframework.data.util.ReflectionUtils.isKotlinClass(type)) { return KotlinCopyMethod.findCopyMethod(type).filter(it -> it.supportsProperty(property)).isPresent(); } return false; } }
if (org.springframework.data.util.ReflectionUtils.isKotlinClass(property.getOwner().getType())) {
/** * Returns whether a {@link PersistentEntity} instance should be created for the given {@link TypeInformation}. By * default this will reject all types considered simple and non-supported Kotlin classes, but it might be necessary to * tweak that in case you have registered custom converters for top level types (which renders them to be considered * simple) but still need meta-information about them. * <p/> * * @param type will never be {@literal null}. * @return */ protected boolean shouldCreatePersistentEntityFor(TypeInformation<?> type) { if (simpleTypeHolder.isSimpleType(type.getType())) { return false; } return !org.springframework.data.util.ReflectionUtils.isKotlinClass(type.getType()) || org.springframework.data.util.ReflectionUtils.isSupportedKotlinClass(type.getType()); }