fun add(name:String, email:String): Result<Customer, DuplicateException>
fun find(id: String): Optional<Customer>
}
IRegisterCustomers
는 여전히 자바 코드이며 여전히 두 가지 예외를 던진다.
예제
19.21
[
errors
.
15
:
src
/
main
/
java
/
travelator
/
IRegisterCustomers
.
java
]
public interface IRegisterCustomers {
Customer register(RegistrationData data)
throws ExcludedException, DuplicateException;
}
CustomerRegistration
은 이제 코틀린 코드이며, 이제는
Result
.
Error
를
throw
를 사용해
DuplicateException
로 연결해 준다.
예제
19.22
[
errors
.
15
:
src
/
main
/
java
/
travelator
/
CustomerRegistration
.
kt
]
class CustomerRegistration( ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.