I have bunch of data classes, with values that need to be nullable since there is possibility of database returning null for some fields.
However, when mapped to ApiClass, these values should be replaced with empty strings or certain Long values ( no nulls )
But i cant figure how to for example turn Long?
to Long
in mapper i have for example
dueDilligence.info.extendedInfo.income.let { it }
which to my knowledge should only pass this value to ApiClass constructor if Long is actual long and not null, if it is null i would assume it will remain in default value given in constructos ( 0 in this case )
dueDilligence.info.extendedInfo.income is a Long that might also be null, but in case of null it should be mapped as 0.
But since data class is Long? and mapper is Long, there is type mismatch which i cant seem to solve with let
or run
i can also write if( attribute == null ) { }
but that will generate soooo much excess code since there is something like 50 attributes.