Skip to content

Commit

Permalink
refactor: 분기가 3개이상일시에 if-> when을 사용
Browse files Browse the repository at this point in the history
  • Loading branch information
rhkrwngud445 committed Mar 31, 2024
1 parent ef5c4c1 commit e1afaa9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.withpeace.withpeace.core.data.mapper

import com.withpeace.withpeace.core.domain.model.profile.ChangedProfile
import com.withpeace.withpeace.core.domain.model.profile.Nickname
import com.withpeace.withpeace.core.network.di.response.ChangedProfileResponse

fun ChangedProfileResponse.toDomain(): ChangedProfile {
return ChangedProfile(
nickname = this.nickname,
nickname = Nickname.create(this.nickname),
profileImageUrl = profileImageUrl,
)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.withpeace.withpeace.core.domain.model.profile

data class ChangedProfile(
val nickname: String,
val profileImageUrl: String,
val nickname: Nickname?,
val profileImageUrl: String?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ sealed interface ProfileChangingStatus {
beforeProfile: ChangingProfileInfo,
afterProfile: ChangingProfileInfo,
): ProfileChangingStatus {
return if (beforeProfile.profileImage != afterProfile.profileImage
&& afterProfile.nickname != beforeProfile.nickname && afterProfile.profileImage != null
) {
AllChanging
} else if (afterProfile.profileImage != null && beforeProfile.profileImage != afterProfile.profileImage
) {
OnlyImageChanging
} else {
OnlyNicknameChanging
return when {
beforeProfile.profileImage != afterProfile.profileImage &&
afterProfile.nickname != beforeProfile.nickname &&
afterProfile.profileImage != null -> AllChanging

afterProfile.profileImage != null &&
beforeProfile.profileImage != afterProfile.profileImage -> OnlyImageChanging

else -> OnlyNicknameChanging
}
}
}
Expand Down

0 comments on commit e1afaa9

Please sign in to comment.