From 287bdb4ad5468896e5d82e9499791994b3dfd18e Mon Sep 17 00:00:00 2001 From: stefankoppier Date: Thu, 1 Aug 2024 19:55:06 +0200 Subject: [PATCH 1/5] Fix analysis warnings --- .../tech/mappie/resolving/classes/ObjectMappingSource.kt | 3 +-- .../validation/problems/MultipleTransformationsProblems.kt | 3 +-- .../problems/UnsafePlatformTypeAssignmentProblems.kt | 2 +- .../validation/problems/UnsafeTypeAssignmentProblems.kt | 5 ++--- .../testing/MapperClassCanContainAllDeclarationsTest.kt | 2 +- .../kotlin/tech/mappie/testing/builtin/FloatMappersTest.kt | 1 - .../test/kotlin/tech/mappie/testing/objects/SetMethodTest.kt | 1 - .../tech/mappie/testing/compilation/KotlinCompilation.kt | 1 - 8 files changed, 6 insertions(+), 12 deletions(-) diff --git a/compiler-plugin/src/main/kotlin/tech/mappie/resolving/classes/ObjectMappingSource.kt b/compiler-plugin/src/main/kotlin/tech/mappie/resolving/classes/ObjectMappingSource.kt index f0eedc04..770f7270 100644 --- a/compiler-plugin/src/main/kotlin/tech/mappie/resolving/classes/ObjectMappingSource.kt +++ b/compiler-plugin/src/main/kotlin/tech/mappie/resolving/classes/ObjectMappingSource.kt @@ -33,8 +33,7 @@ data class PropertySource( if (transformation.isEmpty()) { getter.owner.returnType } else { - val transformation = transformation.first() - when (transformation) { + when (val transformation = transformation.first()) { is MappieTransformOperator -> (transformation.type as IrSimpleType).arguments[1].typeOrFail is MappieViaOperator -> if (getter.owner.returnType.isNullable()) transformation.type.makeNullable() else transformation.type is MappieViaResolved -> if (getter.owner.returnType.isNullable()) transformation.type.makeNullable() else transformation.type diff --git a/compiler-plugin/src/main/kotlin/tech/mappie/validation/problems/MultipleTransformationsProblems.kt b/compiler-plugin/src/main/kotlin/tech/mappie/validation/problems/MultipleTransformationsProblems.kt index 61a71a55..f500cb39 100644 --- a/compiler-plugin/src/main/kotlin/tech/mappie/validation/problems/MultipleTransformationsProblems.kt +++ b/compiler-plugin/src/main/kotlin/tech/mappie/validation/problems/MultipleTransformationsProblems.kt @@ -8,8 +8,7 @@ import tech.mappie.validation.Problem class MultipleTransformationsProblems(private val mappings: Map>) { fun all(): List = mappings.map { (_, sources) -> - val source = sources.single() - when (source) { + when (val source = sources.single()) { is ResolvedSource -> source.transformation is PropertySource -> source.transformation else -> null diff --git a/compiler-plugin/src/main/kotlin/tech/mappie/validation/problems/UnsafePlatformTypeAssignmentProblems.kt b/compiler-plugin/src/main/kotlin/tech/mappie/validation/problems/UnsafePlatformTypeAssignmentProblems.kt index 77e32ea2..dec195a2 100644 --- a/compiler-plugin/src/main/kotlin/tech/mappie/validation/problems/UnsafePlatformTypeAssignmentProblems.kt +++ b/compiler-plugin/src/main/kotlin/tech/mappie/validation/problems/UnsafePlatformTypeAssignmentProblems.kt @@ -17,7 +17,7 @@ class UnsafePlatformTypeAssignmentProblems( private val mappings: List>, ) { - fun all(): List = mappings.map { validate(it.first, it.second) }.filterNotNull() + fun all(): List = mappings.mapNotNull { validate(it.first, it.second) } private fun validate(target: MappieTarget, source: ObjectMappingSource): Problem? { val sourceTypeString = source.type.removeAnnotations().dumpKotlinLike() diff --git a/compiler-plugin/src/main/kotlin/tech/mappie/validation/problems/UnsafeTypeAssignmentProblems.kt b/compiler-plugin/src/main/kotlin/tech/mappie/validation/problems/UnsafeTypeAssignmentProblems.kt index 211ecaa1..75d3904a 100644 --- a/compiler-plugin/src/main/kotlin/tech/mappie/validation/problems/UnsafeTypeAssignmentProblems.kt +++ b/compiler-plugin/src/main/kotlin/tech/mappie/validation/problems/UnsafeTypeAssignmentProblems.kt @@ -20,7 +20,7 @@ class UnsafeTypeAssignmentProblems( private val mappings: List>, ) { - fun all(): List = mappings.map { validate(it.first, it.second) }.filterNotNull() + fun all(): List = mappings.mapNotNull { validate(it.first, it.second) } private fun validate(target: MappieTarget, source: ObjectMappingSource): Problem? { val sourceTypeString = source.type.dumpKotlinLike() @@ -43,7 +43,7 @@ class UnsafeTypeAssignmentProblems( Problem.error(description, null) } is ValueSource -> { - val location = source.origin?.let { location(file, it) } + val location = location(file, source.origin) val description = "Target $targetString of type $targetTypeString cannot be assigned from value of type $sourceTypeString" Problem.error(description, location) } @@ -53,7 +53,6 @@ class UnsafeTypeAssignmentProblems( } } - companion object { fun of(file: IrFileEntry, mapping: ConstructorCallMapping): UnsafeTypeAssignmentProblems { val mappings = mapping.mappings diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/MapperClassCanContainAllDeclarationsTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/MapperClassCanContainAllDeclarationsTest.kt index 4cb64aec..4c999cf3 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/MapperClassCanContainAllDeclarationsTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/MapperClassCanContainAllDeclarationsTest.kt @@ -18,7 +18,7 @@ class MapperClassCanContainAllDeclarationsTest { lateinit var directory: File @Test - fun `"mapper containaining all kind of declarations should succeed`() { + fun `mapper containing all kind of declarations should succeed`() { KotlinCompilation(directory).apply { sources = buildList { add( diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/FloatMappersTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/FloatMappersTest.kt index 2c8cf5d8..9633a0b1 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/FloatMappersTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/FloatMappersTest.kt @@ -9,7 +9,6 @@ import tech.mappie.testing.compilation.SourceFile.Companion.kotlin import tech.mappie.testing.loadObjectMappieClass import java.io.File import java.math.BigDecimal -import java.math.BigInteger class FloatMappersTest { diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/SetMethodTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/SetMethodTest.kt index fed8b72d..0f979e65 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/SetMethodTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/objects/SetMethodTest.kt @@ -1,7 +1,6 @@ package tech.mappie.testing.objects import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.io.TempDir import tech.mappie.testing.compilation.KotlinCompilation diff --git a/compiler-plugin/src/testFixtures/kotlin/tech/mappie/testing/compilation/KotlinCompilation.kt b/compiler-plugin/src/testFixtures/kotlin/tech/mappie/testing/compilation/KotlinCompilation.kt index f2dd1d50..6d2aa99d 100644 --- a/compiler-plugin/src/testFixtures/kotlin/tech/mappie/testing/compilation/KotlinCompilation.kt +++ b/compiler-plugin/src/testFixtures/kotlin/tech/mappie/testing/compilation/KotlinCompilation.kt @@ -18,7 +18,6 @@ package tech.mappie.testing.compilation import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler -import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi import org.jetbrains.kotlin.config.JVMAssertionsMode import org.jetbrains.kotlin.config.JvmTarget import java.io.* From a7c908da8e437b6a2f1f63937804ab717792e63c Mon Sep 17 00:00:00 2001 From: stefankoppier Date: Thu, 1 Aug 2024 20:14:46 +0200 Subject: [PATCH 2/5] Added numeric to string mappers --- .../resolving/MappieDefinitionsCollector.kt | 8 ++ .../testing/builtin/BigDecimalMappersTest.kt | 90 +++++++++++++++++++ .../testing/builtin/BigIntegerMappersTest.kt | 90 +++++++++++++++++++ .../mappie/testing/builtin/ByteMappersTest.kt | 71 +++++++++++++++ .../mappie/testing/builtin/CharMappersTest.kt | 2 +- .../testing/builtin/DoubleMappersTest.kt | 72 +++++++++++++++ .../testing/builtin/FloatMappersTest.kt | 71 +++++++++++++++ .../mappie/testing/builtin/IntMappersTest.kt | 71 +++++++++++++++ .../mappie/testing/builtin/LongMappersTest.kt | 2 + .../testing/builtin/ShortMappersTest.kt | 2 + .../tech/mappie/api/builtin/ByteMappers.kt | 5 ++ .../tech/mappie/api/builtin/DoubleMappers.kt | 8 ++ .../tech/mappie/api/builtin/FloatMappers.kt | 7 +- .../tech/mappie/api/builtin/IntMappers.kt | 5 ++ .../tech/mappie/api/builtin/LongMappers.kt | 8 ++ .../tech/mappie/api/builtin/ShortMappers.kt | 5 ++ .../mappie/api/builtin/BigDecimalMappers.kt | 9 ++ .../mappie/api/builtin/BigIntegerMappers.kt | 9 ++ 18 files changed, 533 insertions(+), 2 deletions(-) create mode 100644 compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/BigDecimalMappersTest.kt create mode 100644 compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/BigIntegerMappersTest.kt create mode 100644 mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/DoubleMappers.kt create mode 100644 mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/LongMappers.kt create mode 100644 mappie-api/src/jvmMain/kotlin/tech/mappie/api/builtin/BigDecimalMappers.kt create mode 100644 mappie-api/src/jvmMain/kotlin/tech/mappie/api/builtin/BigIntegerMappers.kt diff --git a/compiler-plugin/src/main/kotlin/tech/mappie/resolving/MappieDefinitionsCollector.kt b/compiler-plugin/src/main/kotlin/tech/mappie/resolving/MappieDefinitionsCollector.kt index 186a617b..fa8a0677 100644 --- a/compiler-plugin/src/main/kotlin/tech/mappie/resolving/MappieDefinitionsCollector.kt +++ b/compiler-plugin/src/main/kotlin/tech/mappie/resolving/MappieDefinitionsCollector.kt @@ -35,21 +35,29 @@ class BuiltinMappieDefinitionsCollector { "CharToStringMapper", "LongToBigIntegerMapper", "LongToBigDecimalMapper", + "LongToStringMapper", "IntToLongMapper", "IntToBigIntegerMapper", "IntToBigDecimalMapper", + "IntToStringMapper", "ShortToIntMapper", "ShortToLongMapper", "ShortToBigIntegerMapper", "ShortToBigDecimalMapper", + "ShortToStringMapper", "ByteToShortMapper", "ByteToIntMapper", "ByteToLongMapper", "ByteToBigIntegerMapper", "ByteToBigDecimalMapper", + "ByteToStringMapper", "FloatToDoubleMapper", "FloatToBigDecimalMapper", + "FloatToStringMapper", "DoubleToBigDecimalMapper", + "DoubleToStringMapper", + "BigIntegerToStringMapper", + "BigDecimalToStringMapper", ) } } diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/BigDecimalMappersTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/BigDecimalMappersTest.kt new file mode 100644 index 00000000..0787ec7d --- /dev/null +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/BigDecimalMappersTest.kt @@ -0,0 +1,90 @@ +package tech.mappie.testing.builtin + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.io.TempDir +import tech.mappie.testing.compilation.KotlinCompilation +import tech.mappie.testing.compilation.KotlinCompilation.ExitCode +import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.loadObjectMappieClass +import java.io.File +import java.math.BigDecimal + +class BigDecimalMappersTest { + + @TempDir + lateinit var directory: File + + data class BigDecimalInput(val value: BigDecimal) + + data class StringOutput(val value: String) + + @Test + fun `map BigDecimal to String implicit should succeed`() { + KotlinCompilation(directory).apply { + sources = buildList { + add( + kotlin("Test.kt", + """ + import tech.mappie.api.ObjectMappie + import tech.mappie.testing.builtin.BigDecimalMappersTest.* + + class Mapper : ObjectMappie() + """ + ) + ) + } + }.compile { + assertThat(exitCode).isEqualTo(ExitCode.OK) + assertThat(messages).isEmpty() + + val input = BigDecimal.valueOf(10) + + val mapper = classLoader + .loadObjectMappieClass("Mapper") + .constructors + .first() + .call() + + assertThat(mapper.map(BigDecimalInput(input))) + .isEqualTo(StringOutput(input.toString())) + } + } + + @Test + fun `map BigDecimal to String explicit should succeed`() { + KotlinCompilation(directory).apply { + sources = buildList { + add( + kotlin("Test.kt", + """ + import tech.mappie.api.ObjectMappie + import tech.mappie.api.builtin.* + import tech.mappie.testing.builtin.BigDecimalMappersTest.* + + class Mapper : ObjectMappie() { + override fun map(from: BigDecimalInput) = mapping { + to::value fromProperty from::value via BigDecimalToStringMapper() + } + } + """ + ) + ) + } + }.compile { + assertThat(exitCode).isEqualTo(ExitCode.OK) + assertThat(messages).isEmpty() + + val input = BigDecimal.valueOf(100) + + val mapper = classLoader + .loadObjectMappieClass("Mapper") + .constructors + .first() + .call() + + assertThat(mapper.map(BigDecimalInput(input))) + .isEqualTo(StringOutput(input.toString())) + } + } +} diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/BigIntegerMappersTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/BigIntegerMappersTest.kt new file mode 100644 index 00000000..88455ffb --- /dev/null +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/BigIntegerMappersTest.kt @@ -0,0 +1,90 @@ +package tech.mappie.testing.builtin + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.io.TempDir +import tech.mappie.testing.compilation.KotlinCompilation +import tech.mappie.testing.compilation.KotlinCompilation.ExitCode +import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.loadObjectMappieClass +import java.io.File +import java.math.BigInteger + +class BigIntegerMappersTest { + + @TempDir + lateinit var directory: File + + data class BigIntegerInput(val value: BigInteger) + + data class StringOutput(val value: String) + + @Test + fun `map BigInteger to String implicit should succeed`() { + KotlinCompilation(directory).apply { + sources = buildList { + add( + kotlin("Test.kt", + """ + import tech.mappie.api.ObjectMappie + import tech.mappie.testing.builtin.BigIntegerMappersTest.* + + class Mapper : ObjectMappie() + """ + ) + ) + } + }.compile { + assertThat(exitCode).isEqualTo(ExitCode.OK) + assertThat(messages).isEmpty() + + val input = BigInteger.valueOf(10) + + val mapper = classLoader + .loadObjectMappieClass("Mapper") + .constructors + .first() + .call() + + assertThat(mapper.map(BigIntegerInput(input))) + .isEqualTo(StringOutput(input.toString())) + } + } + + @Test + fun `map BigInteger to String explicit should succeed`() { + KotlinCompilation(directory).apply { + sources = buildList { + add( + kotlin("Test.kt", + """ + import tech.mappie.api.ObjectMappie + import tech.mappie.api.builtin.* + import tech.mappie.testing.builtin.BigIntegerMappersTest.* + + class Mapper : ObjectMappie() { + override fun map(from: BigIntegerInput) = mapping { + to::value fromProperty from::value via BigIntegerToStringMapper() + } + } + """ + ) + ) + } + }.compile { + assertThat(exitCode).isEqualTo(ExitCode.OK) + assertThat(messages).isEmpty() + + val input = BigInteger.valueOf(100) + + val mapper = classLoader + .loadObjectMappieClass("Mapper") + .constructors + .first() + .call() + + assertThat(mapper.map(BigIntegerInput(input))) + .isEqualTo(StringOutput(input.toString())) + } + } +} diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/ByteMappersTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/ByteMappersTest.kt index 4e4c707d..a25da206 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/ByteMappersTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/ByteMappersTest.kt @@ -28,6 +28,8 @@ class ByteMappersTest { data class BigDecimalOutput(val value: BigDecimal) + data class StringOutput(val value: String) + @Test fun `map Byte to Short implicit should succeed`() { KotlinCompilation(directory).apply { @@ -372,4 +374,73 @@ class ByteMappersTest { .isEqualTo(BigDecimalOutput(BigDecimal.valueOf(input.toLong()))) } } + + @Test + fun `map Byte to String implicit should succeed`() { + KotlinCompilation(directory).apply { + sources = buildList { + add( + kotlin("Test.kt", + """ + import tech.mappie.api.ObjectMappie + import tech.mappie.testing.builtin.ByteMappersTest.* + + class Mapper : ObjectMappie() + """ + ) + ) + } + }.compile { + assertThat(exitCode).isEqualTo(ExitCode.OK) + assertThat(messages).isEmpty() + + val input: Byte = 2 + + val mapper = classLoader + .loadObjectMappieClass("Mapper") + .constructors + .first() + .call() + + assertThat(mapper.map(ByteInput(input))) + .isEqualTo(StringOutput(input.toString())) + } + } + + @Test + fun `map Byte to String explicit should succeed`() { + KotlinCompilation(directory).apply { + sources = buildList { + add( + kotlin("Test.kt", + """ + import tech.mappie.api.ObjectMappie + import tech.mappie.api.builtin.* + import tech.mappie.testing.builtin.ByteMappersTest.* + + class Mapper : ObjectMappie() { + override fun map(from: ByteInput) = mapping { + to::value fromProperty from::value via ByteToStringMapper() + } + } + """ + ) + ) + } + }.compile { + assertThat(exitCode).isEqualTo(ExitCode.OK) + assertThat(messages).isEmpty() + + val input: Byte = 5 + + val mapper = classLoader + .loadObjectMappieClass("Mapper") + .constructors + .first() + .call() + + assertThat(mapper.map(ByteInput(input))) + .isEqualTo(StringOutput(input.toString())) + } + } } \ No newline at end of file diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/CharMappersTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/CharMappersTest.kt index de1be2be..6867460a 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/CharMappersTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/CharMappersTest.kt @@ -51,7 +51,7 @@ class CharMappersTest { } @Test - fun `map Long to BigInteger explicit should succeed`() { + fun `map Char to String explicit should succeed`() { KotlinCompilation(directory).apply { sources = buildList { add( diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/DoubleMappersTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/DoubleMappersTest.kt index 1186b107..e7a3e030 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/DoubleMappersTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/DoubleMappersTest.kt @@ -3,6 +3,7 @@ package tech.mappie.testing.builtin import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.io.TempDir +import tech.mappie.testing.builtin.ByteMappersTest.* import tech.mappie.testing.compilation.KotlinCompilation import tech.mappie.testing.compilation.KotlinCompilation.ExitCode import tech.mappie.testing.compilation.SourceFile.Companion.kotlin @@ -19,6 +20,8 @@ class DoubleMappersTest { data class BigDecimalOutput(val value: BigDecimal) + data class StringOutput(val value: String) + @Test fun `map Double to BigDecimal implicit should succeed`() { KotlinCompilation(directory).apply { @@ -87,4 +90,73 @@ class DoubleMappersTest { .isEqualTo(BigDecimalOutput(input.toBigDecimal())) } } + + @Test + fun `map Double to String implicit should succeed`() { + KotlinCompilation(directory).apply { + sources = buildList { + add( + kotlin("Test.kt", + """ + import tech.mappie.api.ObjectMappie + import tech.mappie.testing.builtin.DoubleMappersTest.* + + class Mapper : ObjectMappie() + """ + ) + ) + } + }.compile { + assertThat(exitCode).isEqualTo(ExitCode.OK) + assertThat(messages).isEmpty() + + val input = 2.0 + + val mapper = classLoader + .loadObjectMappieClass("Mapper") + .constructors + .first() + .call() + + assertThat(mapper.map(DoubleInput(input))) + .isEqualTo(StringOutput(input.toString())) + } + } + + @Test + fun `map Double to String explicit should succeed`() { + KotlinCompilation(directory).apply { + sources = buildList { + add( + kotlin("Test.kt", + """ + import tech.mappie.api.ObjectMappie + import tech.mappie.api.builtin.* + import tech.mappie.testing.builtin.DoubleMappersTest.* + + class Mapper : ObjectMappie() { + override fun map(from: DoubleInput) = mapping { + to::value fromProperty from::value via DoubleToStringMapper() + } + } + """ + ) + ) + } + }.compile { + assertThat(exitCode).isEqualTo(ExitCode.OK) + assertThat(messages).isEmpty() + + val input = 5.0 + + val mapper = classLoader + .loadObjectMappieClass("Mapper") + .constructors + .first() + .call() + + assertThat(mapper.map(DoubleInput(input))) + .isEqualTo(StringOutput(input.toString())) + } + } } \ No newline at end of file diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/FloatMappersTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/FloatMappersTest.kt index 9633a0b1..496a6d10 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/FloatMappersTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/FloatMappersTest.kt @@ -21,6 +21,8 @@ class FloatMappersTest { data class BigDecimalOutput(val value: BigDecimal) + data class StringOutput(val value: String) + @Test fun `map Float to Double implicit should succeed`() { KotlinCompilation(directory).apply { @@ -158,4 +160,73 @@ class FloatMappersTest { .isEqualTo(BigDecimalOutput(input.toBigDecimal())) } } + + @Test + fun `map Float to String implicit should succeed`() { + KotlinCompilation(directory).apply { + sources = buildList { + add( + kotlin("Test.kt", + """ + import tech.mappie.api.ObjectMappie + import tech.mappie.testing.builtin.FloatMappersTest.* + + class Mapper : ObjectMappie() + """ + ) + ) + } + }.compile { + assertThat(exitCode).isEqualTo(ExitCode.OK) + assertThat(messages).isEmpty() + + val input = 2.0f + + val mapper = classLoader + .loadObjectMappieClass("Mapper") + .constructors + .first() + .call() + + assertThat(mapper.map(FloatInput(input))) + .isEqualTo(StringOutput(input.toString())) + } + } + + @Test + fun `map Float to String explicit should succeed`() { + KotlinCompilation(directory).apply { + sources = buildList { + add( + kotlin("Test.kt", + """ + import tech.mappie.api.ObjectMappie + import tech.mappie.api.builtin.* + import tech.mappie.testing.builtin.FloatMappersTest.* + + class Mapper : ObjectMappie() { + override fun map(from: FloatInput) = mapping { + to::value fromProperty from::value via FloatToStringMapper() + } + } + """ + ) + ) + } + }.compile { + assertThat(exitCode).isEqualTo(ExitCode.OK) + assertThat(messages).isEmpty() + + val input = 5.0f + + val mapper = classLoader + .loadObjectMappieClass("Mapper") + .constructors + .first() + .call() + + assertThat(mapper.map(FloatInput(input))) + .isEqualTo(StringOutput(input.toString())) + } + } } \ No newline at end of file diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/IntMappersTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/IntMappersTest.kt index d7b0b34f..c61d9012 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/IntMappersTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/IntMappersTest.kt @@ -24,6 +24,8 @@ class IntMappersTest { data class BigDecimalOutput(val value: BigDecimal) + data class StringOutput(val value: String) + @Test fun `map Int to Long implicit should succeed`() { KotlinCompilation(directory).apply { @@ -230,4 +232,73 @@ class IntMappersTest { .isEqualTo(BigDecimalOutput(input.toBigDecimal())) } } + + @Test + fun `map Int to String implicit should succeed`() { + KotlinCompilation(directory).apply { + sources = buildList { + add( + kotlin("Test.kt", + """ + import tech.mappie.api.ObjectMappie + import tech.mappie.testing.builtin.IntMappersTest.* + + class Mapper : ObjectMappie() + """ + ) + ) + } + }.compile { + assertThat(exitCode).isEqualTo(ExitCode.OK) + assertThat(messages).isEmpty() + + val input = 2 + + val mapper = classLoader + .loadObjectMappieClass("Mapper") + .constructors + .first() + .call() + + assertThat(mapper.map(IntInput(input))) + .isEqualTo(StringOutput(input.toString())) + } + } + + @Test + fun `map Int to String explicit should succeed`() { + KotlinCompilation(directory).apply { + sources = buildList { + add( + kotlin("Test.kt", + """ + import tech.mappie.api.ObjectMappie + import tech.mappie.api.builtin.* + import tech.mappie.testing.builtin.IntMappersTest.* + + class Mapper : ObjectMappie() { + override fun map(from: IntInput) = mapping { + to::value fromProperty from::value via IntToStringMapper() + } + } + """ + ) + ) + } + }.compile { + assertThat(exitCode).isEqualTo(ExitCode.OK) + assertThat(messages).isEmpty() + + val input = 5 + + val mapper = classLoader + .loadObjectMappieClass("Mapper") + .constructors + .first() + .call() + + assertThat(mapper.map(IntInput(input))) + .isEqualTo(StringOutput(input.toString())) + } + } } \ No newline at end of file diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/LongMappersTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/LongMappersTest.kt index b1e462fa..99c6c061 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/LongMappersTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/LongMappersTest.kt @@ -22,6 +22,8 @@ class LongMappersTest { data class BigDecimalOutput(val value: BigDecimal) + data class StringOutput(val value: String) + @Test fun `map Long to BigInteger implicit should succeed`() { KotlinCompilation(directory).apply { diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/ShortMappersTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/ShortMappersTest.kt index 23b55a7b..54c85bc4 100644 --- a/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/ShortMappersTest.kt +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/ShortMappersTest.kt @@ -26,6 +26,8 @@ class ShortMappersTest { data class BigDecimalOutput(val value: BigDecimal) + data class StringOutput(val value: String) + @Test fun `map Short to Int implicit should succeed`() { KotlinCompilation(directory).apply { diff --git a/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/ByteMappers.kt b/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/ByteMappers.kt index bce0ea1d..99a7b9dd 100644 --- a/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/ByteMappers.kt +++ b/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/ByteMappers.kt @@ -16,3 +16,8 @@ public class ByteToLongMapper : ObjectMappie() { override fun map(from: Byte): Long = from.toLong() } + +public class ByteToStringMapper : ObjectMappie() { + override fun map(from: Byte): String = + from.toString() +} diff --git a/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/DoubleMappers.kt b/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/DoubleMappers.kt new file mode 100644 index 00000000..5b71b633 --- /dev/null +++ b/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/DoubleMappers.kt @@ -0,0 +1,8 @@ +package tech.mappie.api.builtin + +import tech.mappie.api.ObjectMappie + +public class DoubleToStringMapper : ObjectMappie() { + override fun map(from: Double): String = + from.toString() +} diff --git a/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/FloatMappers.kt b/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/FloatMappers.kt index 32076c8f..887062a5 100644 --- a/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/FloatMappers.kt +++ b/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/FloatMappers.kt @@ -5,4 +5,9 @@ import tech.mappie.api.ObjectMappie public class FloatToDoubleMapper : ObjectMappie() { override fun map(from: Float): Double = from.toDouble() -} \ No newline at end of file +} + +public class FloatToStringMapper : ObjectMappie() { + override fun map(from: Float): String = + from.toString() +} diff --git a/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/IntMappers.kt b/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/IntMappers.kt index a082db74..59fcea70 100644 --- a/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/IntMappers.kt +++ b/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/IntMappers.kt @@ -6,3 +6,8 @@ public class IntToLongMapper : ObjectMappie() { override fun map(from: Int): Long = from.toLong() } + +public class IntToStringMapper : ObjectMappie() { + override fun map(from: Int): String = + from.toString() +} diff --git a/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/LongMappers.kt b/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/LongMappers.kt new file mode 100644 index 00000000..88dbd3a7 --- /dev/null +++ b/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/LongMappers.kt @@ -0,0 +1,8 @@ +package tech.mappie.api.builtin + +import tech.mappie.api.ObjectMappie + +public class LongToStringMapper : ObjectMappie() { + override fun map(from: Long): String = + from.toString() +} diff --git a/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/ShortMappers.kt b/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/ShortMappers.kt index ada9f720..3984f682 100644 --- a/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/ShortMappers.kt +++ b/mappie-api/src/commonMain/kotlin/tech/mappie/api/builtin/ShortMappers.kt @@ -11,3 +11,8 @@ public class ShortToLongMapper : ObjectMappie() { override fun map(from: Short): Long = from.toLong() } + +public class ShortToStringMapper : ObjectMappie() { + override fun map(from: Short): String = + from.toString() +} diff --git a/mappie-api/src/jvmMain/kotlin/tech/mappie/api/builtin/BigDecimalMappers.kt b/mappie-api/src/jvmMain/kotlin/tech/mappie/api/builtin/BigDecimalMappers.kt new file mode 100644 index 00000000..def428e9 --- /dev/null +++ b/mappie-api/src/jvmMain/kotlin/tech/mappie/api/builtin/BigDecimalMappers.kt @@ -0,0 +1,9 @@ +package tech.mappie.api.builtin + +import tech.mappie.api.ObjectMappie +import java.math.BigDecimal + +public class BigDecimalToStringMapper : ObjectMappie() { + override fun map(from: BigDecimal): String = + from.toString() +} diff --git a/mappie-api/src/jvmMain/kotlin/tech/mappie/api/builtin/BigIntegerMappers.kt b/mappie-api/src/jvmMain/kotlin/tech/mappie/api/builtin/BigIntegerMappers.kt new file mode 100644 index 00000000..7d936c82 --- /dev/null +++ b/mappie-api/src/jvmMain/kotlin/tech/mappie/api/builtin/BigIntegerMappers.kt @@ -0,0 +1,9 @@ +package tech.mappie.api.builtin + +import tech.mappie.api.ObjectMappie +import java.math.BigInteger + +public class BigIntegerToStringMapper : ObjectMappie() { + override fun map(from: BigInteger): String = + from.toString() +} From e0c21c329ed938031579285cd7adfa889f851dd0 Mon Sep 17 00:00:00 2001 From: stefankoppier Date: Thu, 1 Aug 2024 20:20:43 +0200 Subject: [PATCH 3/5] Added UUID to string mappers --- .../resolving/MappieDefinitionsCollector.kt | 1 + .../mappie/testing/builtin/UUIDMappersTest.kt | 90 +++++++++++++++++++ .../tech/mappie/api/builtin/UUIDMappers.kt | 9 ++ 3 files changed, 100 insertions(+) create mode 100644 compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/UUIDMappersTest.kt create mode 100644 mappie-api/src/jvmMain/kotlin/tech/mappie/api/builtin/UUIDMappers.kt diff --git a/compiler-plugin/src/main/kotlin/tech/mappie/resolving/MappieDefinitionsCollector.kt b/compiler-plugin/src/main/kotlin/tech/mappie/resolving/MappieDefinitionsCollector.kt index fa8a0677..120305ef 100644 --- a/compiler-plugin/src/main/kotlin/tech/mappie/resolving/MappieDefinitionsCollector.kt +++ b/compiler-plugin/src/main/kotlin/tech/mappie/resolving/MappieDefinitionsCollector.kt @@ -58,6 +58,7 @@ class BuiltinMappieDefinitionsCollector { "DoubleToStringMapper", "BigIntegerToStringMapper", "BigDecimalToStringMapper", + "UUIDToStringMapper", ) } } diff --git a/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/UUIDMappersTest.kt b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/UUIDMappersTest.kt new file mode 100644 index 00000000..79bb43b4 --- /dev/null +++ b/compiler-plugin/src/test/kotlin/tech/mappie/testing/builtin/UUIDMappersTest.kt @@ -0,0 +1,90 @@ +package tech.mappie.testing.builtin + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.io.TempDir +import tech.mappie.testing.compilation.KotlinCompilation +import tech.mappie.testing.compilation.KotlinCompilation.ExitCode +import tech.mappie.testing.compilation.SourceFile.Companion.kotlin +import tech.mappie.testing.loadObjectMappieClass +import java.io.File +import java.util.UUID + +class UUIDMappersTest { + + @TempDir + lateinit var directory: File + + data class UUIDInput(val value: UUID) + + data class StringOutput(val value: String) + + @Test + fun `map UUID to String implicit should succeed`() { + KotlinCompilation(directory).apply { + sources = buildList { + add( + kotlin("Test.kt", + """ + import tech.mappie.api.ObjectMappie + import tech.mappie.testing.builtin.UUIDMappersTest.* + + class Mapper : ObjectMappie() + """ + ) + ) + } + }.compile { + assertThat(exitCode).isEqualTo(ExitCode.OK) + assertThat(messages).isEmpty() + + val input = UUID.fromString("749c9041-ce3b-416b-aec7-3be7edf52de9") + + val mapper = classLoader + .loadObjectMappieClass("Mapper") + .constructors + .first() + .call() + + assertThat(mapper.map(UUIDInput(input))) + .isEqualTo(StringOutput(input.toString())) + } + } + + @Test + fun `map UUID to String explicit should succeed`() { + KotlinCompilation(directory).apply { + sources = buildList { + add( + kotlin("Test.kt", + """ + import tech.mappie.api.ObjectMappie + import tech.mappie.api.builtin.* + import tech.mappie.testing.builtin.UUIDMappersTest.* + + class Mapper : ObjectMappie() { + override fun map(from: UUIDInput) = mapping { + to::value fromProperty from::value via UUIDToStringMapper() + } + } + """ + ) + ) + } + }.compile { + assertThat(exitCode).isEqualTo(ExitCode.OK) + assertThat(messages).isEmpty() + + val input = UUID.fromString("8cad0e3d-31d1-4d03-9314-a5e3f3b557b4") + + val mapper = classLoader + .loadObjectMappieClass("Mapper") + .constructors + .first() + .call() + + assertThat(mapper.map(UUIDInput(input))) + .isEqualTo(StringOutput(input.toString())) + } + } +} diff --git a/mappie-api/src/jvmMain/kotlin/tech/mappie/api/builtin/UUIDMappers.kt b/mappie-api/src/jvmMain/kotlin/tech/mappie/api/builtin/UUIDMappers.kt new file mode 100644 index 00000000..289c3819 --- /dev/null +++ b/mappie-api/src/jvmMain/kotlin/tech/mappie/api/builtin/UUIDMappers.kt @@ -0,0 +1,9 @@ +package tech.mappie.api.builtin + +import tech.mappie.api.ObjectMappie +import java.util.UUID + +public class UUIDToStringMapper : ObjectMappie() { + override fun map(from: UUID): String = + from.toString() +} From 40d623c35f8d3b2338e1a9c6c0dc77d8c7d86ae7 Mon Sep 17 00:00:00 2001 From: stefankoppier Date: Thu, 1 Aug 2024 20:20:53 +0200 Subject: [PATCH 4/5] Updated documentation --- website/src/changelog.md | 4 +++ .../posts/object-mapping/posts/built-in.md | 32 ++++++++++++------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/website/src/changelog.md b/website/src/changelog.md index 3c67076c..e3cad00e 100644 --- a/website/src/changelog.md +++ b/website/src/changelog.md @@ -3,6 +3,10 @@ title: "Changelog" layout: "layouts/changelog.html" changelog: - date: "tbd" + title: "v0.7.0" + items: + - "Added more built-in mappers." + - date: "2024-08-31" title: "v0.6.0" items: - "[#69](https://github.com/Mr-Mappie/mappie/issues/69) enum mappers can now be generated automatically if source and target contain the same entries." diff --git a/website/src/posts/object-mapping/posts/built-in.md b/website/src/posts/object-mapping/posts/built-in.md index 249ad36a..dc3d9dc9 100644 --- a/website/src/posts/object-mapping/posts/built-in.md +++ b/website/src/posts/object-mapping/posts/built-in.md @@ -16,14 +16,16 @@ on the JVM platform. ## Numeric Mappers The following numeric mappers are built-int. -| | Byte | Short | Int | Long | Float | Double | *BigInteger* | *BigDecimal* | -|--------|------|-------|-----|------|-------|--------|--------------|--------------| -| Byte | - | X | X | X | | | X | X | -| Short | | - | X | X | | | X | X | -| Int | | | - | X | | | X | X | -| Long | | | | - | | | X | X | -| Float | | | | | - | X | | X | -| Double | | | | | | - | | X | +| | Byte | Short | Int | Long | Float | Double | *BigInteger* | *BigDecimal* | String | +|---------------|------|-------|-----|------|-------|--------|--------------|--------------|--------| +| Byte | - | X | X | X | | | X | X | X | +| Short | | - | X | X | | | X | X | X | +| Int | | | - | X | | | X | X | X | +| Long | | | | - | | | X | X | X | +| Float | | | | | - | X | | X | X | +| Double | | | | | | - | | X | X | +| *BigInteger* | | | | | | | - | | X | +| *BigDecimal* | | | | | | | | - | X | ## Char Mappers The following char mappers are built-int @@ -35,6 +37,14 @@ The following char mappers are built-int ## LocalDate Mappers The following numeric mappers are built-int -| | *LocalTime* | *LocalDate* | -|-----------------|--------------|-------------| -| *LocalDateTime* | X | X | +| | *LocalTime* | *LocalTime* | *LocalDate* | +|-----------------|-------------|-------------|-------------| +| *LocalDateTime* | - | X | X | + + +## Char Mappers +The following UUID mappers are built-int + +| | *UUID* | String | +|--------|--------|--------| +| *UUID* | - | X | \ No newline at end of file From 319636e314490dd67a8bdb5c340a91fca61463f4 Mon Sep 17 00:00:00 2001 From: stefankoppier Date: Thu, 1 Aug 2024 21:02:14 +0200 Subject: [PATCH 5/5] Updated documentation --- website/.eleventy.js | 3 +- website/package-lock.json | 19 +++++++++ website/package.json | 5 ++- website/src/css/main.css | 7 ++++ .../posts/object-mapping/posts/built-in.md | 42 +++++++++++++------ 5 files changed, 60 insertions(+), 16 deletions(-) diff --git a/website/.eleventy.js b/website/.eleventy.js index 51a9cd47..cea891d3 100644 --- a/website/.eleventy.js +++ b/website/.eleventy.js @@ -6,6 +6,7 @@ const eleventyNavigationPlugin = require('@11ty/eleventy-navigation'); const htmlMinTransform = require('./src/transforms/html-min-transform.js'); const isProduction = process.env.NODE_ENV === 'production'; const markdownIt = require('markdown-it'); +const markdownItAttrs = require('markdown-it-attrs'); const markdownItAnchor = require('markdown-it-anchor'); const pluginTOC = require('eleventy-plugin-toc'); const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight'); @@ -52,7 +53,7 @@ module.exports = config => { permalinkClass: 'anchor', permalinkSymbol: '#' } - ); + ).use(markdownItAttrs); config.setLibrary('md', markdownLib); diff --git a/website/package-lock.json b/website/package-lock.json index 8634dc01..40ff9c4a 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -18,6 +18,7 @@ "himalaya": "^1.1.0", "html-minifier-terser": "^7.0.0", "markdown-it-anchor": "^9.0.1", + "markdown-it-attrs": "^4.1.6", "moment": "^2.30.1", "npm-run-all": "^4.1.5", "pagefind": "^1.1.0", @@ -3033,6 +3034,18 @@ "markdown-it": "*" } }, + "node_modules/markdown-it-attrs": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/markdown-it-attrs/-/markdown-it-attrs-4.1.6.tgz", + "integrity": "sha512-O7PDKZlN8RFMyDX13JnctQompwrrILuz2y43pW2GagcwpIIElkAdfeek+erHfxUOlXWPsjFeWmZ8ch1xtRLWpA==", + "license": "MIT", + "engines": { + "node": ">=6" + }, + "peerDependencies": { + "markdown-it": ">= 9.0.0" + } + }, "node_modules/maximatch": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/maximatch/-/maximatch-0.1.0.tgz", @@ -7525,6 +7538,12 @@ "integrity": "sha512-cBt7aAzmkfX8X7FqAe8EBryiKmToXgMQEEMqkXzWCm0toDtfDYIGboKeTKd8cpNJArJtutrf+977wFJTsvNGmQ==", "requires": {} }, + "markdown-it-attrs": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/markdown-it-attrs/-/markdown-it-attrs-4.1.6.tgz", + "integrity": "sha512-O7PDKZlN8RFMyDX13JnctQompwrrILuz2y43pW2GagcwpIIElkAdfeek+erHfxUOlXWPsjFeWmZ8ch1xtRLWpA==", + "requires": {} + }, "maximatch": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/maximatch/-/maximatch-0.1.0.tgz", diff --git a/website/package.json b/website/package.json index e11ce28f..cbbab60b 100644 --- a/website/package.json +++ b/website/package.json @@ -13,8 +13,8 @@ "start": "npm-run-all --parallel eleventy:dev sass:dev" }, "dependencies": { - "@11ty/eleventy-img": "^3.1.0", "@11ty/eleventy": "^2.0.1", + "@11ty/eleventy-img": "^3.1.0", "@11ty/eleventy-navigation": "^0.3.5", "@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0", "del-cli": "^5.1.0", @@ -22,8 +22,9 @@ "eleventy-plugin-toc": "^1.1.5", "himalaya": "^1.1.0", "html-minifier-terser": "^7.0.0", - "moment": "^2.30.1", "markdown-it-anchor": "^9.0.1", + "markdown-it-attrs": "^4.1.6", + "moment": "^2.30.1", "npm-run-all": "^4.1.5", "pagefind": "^1.1.0", "sass": "^1.77.6", diff --git a/website/src/css/main.css b/website/src/css/main.css index 5dcec3b8..7eee37be 100644 --- a/website/src/css/main.css +++ b/website/src/css/main.css @@ -580,6 +580,13 @@ figure figcaption { text-align: center; } +.table-matrix { + overflow-x: auto; + max-width: 95%; + display: block; + width: fit-content; +} + .table-responsive { --inline-size: 40rem; -webkit-overflow-scrolling: touch; diff --git a/website/src/posts/object-mapping/posts/built-in.md b/website/src/posts/object-mapping/posts/built-in.md index dc3d9dc9..0bbb3e59 100644 --- a/website/src/posts/object-mapping/posts/built-in.md +++ b/website/src/posts/object-mapping/posts/built-in.md @@ -14,18 +14,29 @@ The types below that are in *cursive* are not available on all platforms. For ex on the JVM platform. ## Numeric Mappers -The following numeric mappers are built-int. - -| | Byte | Short | Int | Long | Float | Double | *BigInteger* | *BigDecimal* | String | -|---------------|------|-------|-----|------|-------|--------|--------------|--------------|--------| -| Byte | - | X | X | X | | | X | X | X | -| Short | | - | X | X | | | X | X | X | -| Int | | | - | X | | | X | X | X | -| Long | | | | - | | | X | X | X | -| Float | | | | | - | X | | X | X | -| Double | | | | | | - | | X | X | -| *BigInteger* | | | | | | | - | | X | -| *BigDecimal* | | | | | | | | - | X | +The following integer mappers are built-int. + +| | Byte | Short | Int | Long | *BigInteger* | *BigDecimal* | +|--------------|------|-------|-----|------|--------------|---------------| +| Byte | - | X | X | X | X | X | +| Short | | - | X | X | X | X | +| Int | | | - | X | X | X | +| Long | | | | - | X | X | +| *BigInteger* | | | | | - | | +| *BigDecimal* | | | | | | - | + +{.table-matrix} + +The following floating point mappers are built-int. + +| | Float | Double | *BigDecimal* | +|--------------|-------|--------|---------------| +| Float | - | X | X | +| Double | | - | X | + +{.table-matrix} + +There also exist a mapper for all numeric types to `String`. ## Char Mappers The following char mappers are built-int @@ -34,6 +45,8 @@ The following char mappers are built-int |--------|------|--------| | Char | - | X | +{.table-matrix} + ## LocalDate Mappers The following numeric mappers are built-int @@ -41,10 +54,13 @@ The following numeric mappers are built-int |-----------------|-------------|-------------|-------------| | *LocalDateTime* | - | X | X | +{.table-matrix} ## Char Mappers The following UUID mappers are built-int | | *UUID* | String | |--------|--------|--------| -| *UUID* | - | X | \ No newline at end of file +| *UUID* | - | X | + +{.table-matrix}