ContactStore expects the developer to provide an appropriate Label when they use a LabeledValue object. For example, you can represent a 'Mobile' entry as such:
val newMobile = LabeledValue(PhoneNumber("555"), PhoneNumberMobile)
and the object can be used later on in ContactStore.execute(). If the label provided is not a PhoneXYZ one, execute() will throw an exception. For example:
val newMobile = LabeledValue(PhoneNumber("555"), DateBirthday)
will compile and the LabeledValue will be created without an issue. Passing the object to execute() though will cause an exception to be thrown.
An enhancement here would be to provide developers with direct feedback of this behavior. Compilation time would be ideal but hard to maintain. Alternatively failing during Runtime when an incompatible object gets created is also an approach.
ContactStore expects the developer to provide an appropriate
Label
when they use aLabeledValue
object. For example, you can represent a 'Mobile' entry as such:and the object can be used later on in
ContactStore.execute()
. If the label provided is not aPhoneXYZ
one,execute()
will throw an exception. For example:will compile and the LabeledValue will be created without an issue. Passing the object to
execute()
though will cause an exception to be thrown.An enhancement here would be to provide developers with direct feedback of this behavior. Compilation time would be ideal but hard to maintain. Alternatively failing during Runtime when an incompatible object gets created is also an approach.