Fix indentation of Kotlin datamapping examples (#5563)
* Add Kotlin data mapping examples (BAEL-2247) * Fix indentation in Kotlin datamapping examples
This commit is contained in:
parent
758648eb05
commit
018e00c804
|
@ -1,10 +1,10 @@
|
||||||
package com.baeldung.datamapping
|
package com.baeldung.datamapping
|
||||||
|
|
||||||
data class User(
|
data class User(
|
||||||
val firstName: String,
|
val firstName: String,
|
||||||
val lastName: String,
|
val lastName: String,
|
||||||
val street: String,
|
val street: String,
|
||||||
val houseNumber: String,
|
val houseNumber: String,
|
||||||
val phone: String,
|
val phone: String,
|
||||||
val age: Int,
|
val age: Int,
|
||||||
val password: String)
|
val password: String)
|
|
@ -3,10 +3,10 @@ package com.baeldung.datamapping
|
||||||
import kotlin.reflect.full.memberProperties
|
import kotlin.reflect.full.memberProperties
|
||||||
|
|
||||||
fun User.toUserView() = UserView(
|
fun User.toUserView() = UserView(
|
||||||
name = "$firstName $lastName",
|
name = "$firstName $lastName",
|
||||||
address = "$street $houseNumber",
|
address = "$street $houseNumber",
|
||||||
telephone = phone,
|
telephone = phone,
|
||||||
age = age
|
age = age
|
||||||
)
|
)
|
||||||
|
|
||||||
fun User.toUserViewReflection() = with(::UserView) {
|
fun User.toUserViewReflection() = with(::UserView) {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.baeldung.datamapping
|
package com.baeldung.datamapping
|
||||||
|
|
||||||
data class UserView(
|
data class UserView(
|
||||||
val name: String,
|
val name: String,
|
||||||
val address: String,
|
val address: String,
|
||||||
val telephone: String,
|
val telephone: String,
|
||||||
val age: Int
|
val age: Int
|
||||||
)
|
)
|
|
@ -22,22 +22,22 @@ class UserTest {
|
||||||
|
|
||||||
private fun buildUser(): User {
|
private fun buildUser(): User {
|
||||||
return User(
|
return User(
|
||||||
"Java",
|
"Java",
|
||||||
"Duke",
|
"Duke",
|
||||||
"Javastreet",
|
"Javastreet",
|
||||||
"42",
|
"42",
|
||||||
"1234567",
|
"1234567",
|
||||||
30,
|
30,
|
||||||
"s3cr37"
|
"s3cr37"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun assertUserView(pr: UserView) {
|
private fun assertUserView(pr: UserView) {
|
||||||
assertAll(
|
assertAll(
|
||||||
{ assertEquals("Java Duke", pr.name) },
|
{ assertEquals("Java Duke", pr.name) },
|
||||||
{ assertEquals("Javastreet 42", pr.address) },
|
{ assertEquals("Javastreet 42", pr.address) },
|
||||||
{ assertEquals("1234567", pr.telephone) },
|
{ assertEquals("1234567", pr.telephone) },
|
||||||
{ assertEquals(30, pr.age) }
|
{ assertEquals(30, pr.age) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue