File tree Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Expand file tree Collapse file tree 1 file changed +9
-13
lines changed Original file line number Diff line number Diff line change @@ -9,19 +9,15 @@ data class EmailAddress(
9
9
10
10
companion object {
11
11
@JvmStatic
12
- fun parse (value : String ) =
13
- emailAddress(value, value.lastIndexOf(' @' ))
14
-
15
- private fun emailAddress (value : String , atIndex : Int ): EmailAddress =
16
- when {
17
- atIndex < 1 || atIndex == value.length - 1 ->
18
- throw IllegalArgumentException (
19
- " EmailAddress must be two parts separated by @"
20
- )
21
- else -> EmailAddress (
22
- value.substring(0 , atIndex),
23
- value.substring(atIndex + 1 )
24
- )
12
+ fun parse (value : String ): EmailAddress {
13
+ val atIndex = value.lastIndexOf(' @' )
14
+ require(! (atIndex < 1 || atIndex == value.length - 1 )) {
15
+ " EmailAddress must be two parts separated by @"
25
16
}
17
+ return EmailAddress (
18
+ value.substring(0 , atIndex),
19
+ value.substring(atIndex + 1 )
20
+ )
21
+ }
26
22
}
27
23
}
You can’t perform that action at this time.
0 commit comments