DATACMNS-1779 - Consider kotlin.Unit a simple type.

kotlin.Unit is now considered a simple type to avoid PersistentEntity creation.

ReflectionUtils.isVoid(…) now encapsulates the check so that calling code doesn't need to check if Kotlin is on the class path.
This commit is contained in:
Mark Paluch
2020-07-31 10:49:52 +02:00
parent 837dd0789e
commit bb4d621a32
4 changed files with 36 additions and 3 deletions

View File

@@ -17,11 +17,14 @@ package org.springframework.data.util;
import static org.assertj.core.api.Assertions.*;
import kotlin.Unit;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.MethodParameter;
import org.springframework.data.mapping.model.TypeCreatingSyntheticClassKt;
@@ -163,6 +166,15 @@ public class ReflectionUtilsUnitTests {
assertThat(ReflectionUtils.isSupportedKotlinClass(TypeCreatingSyntheticClassKt.class)).isFalse();
}
@Test // DATACMNS-1779
public void shouldReportIsVoid() {
assertThat(ReflectionUtils.isVoid(Void.class)).isTrue();
assertThat(ReflectionUtils.isVoid(Void.TYPE)).isTrue();
assertThat(ReflectionUtils.isVoid(Unit.class)).isTrue();
assertThat(ReflectionUtils.isVoid(String.class)).isFalse();
}
static class Sample {
public String field;