January 2018
Intermediate to advanced
414 pages
10h 29m
English
We have learned how to handle complex objects, but how can we handle them when things are optional? Let's consider that in the previous example, we can set it so that the customer's telephone is something that we may have, but is optional.
First, we need to modify our Customer class, to make the telephone nullable:
package com.microservices.chapter3data class Customer(var id: Int = 0, var name: String = "", var telephone: Telephone? = null) { data class Telephone(var countryCode: String = "", var telephoneNumber: String = "")}
We have set a default value of the telephone as null, so let's modify our service:
package com.microservices.chapter3import com.microservices.chapter3.Customer.Telephoneimport org.springframework.stereotype.Component ...
Read now
Unlock full access