Skip to content

Commit

Permalink
refactor : 불필요한 메서드 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
le2sky committed Sep 27, 2023
1 parent 30f35e4 commit 1e7cdf2
Showing 1 changed file with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import javax.persistence.Embeddable

// TODO : 매번 REGEX 객체를 생성하는 것이 성능에 얼마나 영향을 미치는지 확인하고 개선
private const val BRN_FORMAT = "([0-9]{3})-?([0-9]{2})-?([0-9]{5})"
private const val INVALID_BRN_FORMAT_MESSAGE = "올바른 사업자번호 형식이 아닙니다."

@Embeddable
class ShopBusinessNumber private constructor(
Expand All @@ -15,21 +14,14 @@ class ShopBusinessNumber private constructor(

companion object {
fun from(brn: String): ShopBusinessNumber {
checkIsBrnBlank(brn)
checkIsBrnFormat(brn)

return ShopBusinessNumber(brn)
}

private fun checkIsBrnBlank(brn: String) {
if (brn.isBlank()) {
throw IllegalArgumentException(INVALID_BRN_FORMAT_MESSAGE)
}
}

private fun checkIsBrnFormat(brn: String) {
if (!brn.matches(getBRNFormatRegex())) {
throw IllegalArgumentException(INVALID_BRN_FORMAT_MESSAGE)
throw IllegalArgumentException("올바른 사업자번호 형식이 아닙니다.")
}
}

Expand Down

0 comments on commit 1e7cdf2

Please sign in to comment.