I will be using observable transformer in my application for converting data from one type to another, so for this use i created a generic class with one parameter <T1>
where T1 is the type am expecting to get the output
Example
class Transformer<T1> {
fun transform(): ObservableTransformer<String, T1> {
return ObservableTransformer { data ->
data.map {
if (T1 is Int) { //getting compilation error like T1 is not an expression
return IntDataType
}
if (T1 is Double) { //getting compilation error like T1 is not an expression
return DoubleDataType
}
}
}
}
}
The above class is the transformer which gets the input as string and convert String to someData type based on given generic type T1
So i will be calling the above like this
getSomeData()
.compose(Transformer<Double>().tranform())
.map{ it: double
}
is there is any other solution to perform like this type of transformer ? Any help