I'm wondering if there is an equivalent in Java code for this kotlin sealed class
sealed class Resource<out T> {
class Loading<out T> : Resource<T>()
data class Success<out T>(val data: T) : Resource<T>()
data class Failure<out T>(val exception: Exception) : Resource<T>()
}
Just like that (unfortunately, too verbose):
class Resource<T> {
class Loading extends Resource<T> { }
class Success extends Resource<T> {
@NonNull
T data;
public Success(T data) {
this.data = data;
}
}
class Failure extends Resource<T> {
@NonNull
Exception exception;
public Failure(Exception exception) {
this.exception = exception
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With