Explicit Conversions
Create conversions for custom types
I'm only going to be showing the conversion API in TypeScript for this chapter. There will be a Java API for this, and you should totally use the Java API instead (for speed). However, I prefer to use TypeScript to show how the API will look, it's just nicer. The Java API will have very similar semantics.
Converters
In both directions, converters work the same way fundamentally.
Converters have a predicate and a transformer.
The predicate determines whether or not the converter will apply. For instance, it could check if the object is a String.
Then, the transformer will convert that object into the new datatype.
To Java
From Java
Last updated