To map the result I have implemented sealed generic class :
public sealed class ResultMapper<out T : Any> {
public class Ok<out T : Any>(public val value: T,
override val response: Response) : Result<T>(), ResponseResult {
override fun toString(): String = "Result.Ok{value=$value, response=$response}"
}
}
public interface ResponseResult {
val response: Response
}
Now I suppose to this class should work as expected below behaviour:
ResultMapper.Ok(body,raw)
private class Body<T>() {
onResponse(response: Response, raw: Raw) {
ResultMapper.Ok(response.body(),response.raw()) --> It returned an exception
}
}
Constructor Ok is not satisfied: inferred type T? is not subtype of Any
ResultMapper <out T>
cause many inbuilt class not allow with Any explicit type. Do you think this one is ok ? – Fatimafatimah