Questions tagged [sealed-class]

142 questions
0
votes
1 answer

Firestore (Kotlin) proper way to convert a complete task into a sealed class when performing a document request

I'm trying to experiment a proper way to convert a complete task into a sealed class easy to read when performing a get request on a document (at this time and I will see later for collections request). import…
0
votes
1 answer

Kotlin sealed classes - why doesn't compiler check for all subtypes?

When using sealed classes, the compiler only checks for subtypes in the same file. One of the big selling points of sealed classes is the exhaustive checks when using a when expression. So why isn't this implemented? In 1 file I have: class C :…
Ivan
  • 239
  • 1
  • 13
0
votes
1 answer

How can I configure the Kotlin version used for scratch files in IntelliJ IDEA?

I've recently installed IntelliJ IDEA in an attempt to learn Kotlin. I've set up a Kotlin project and configured IDEA to use the latest stable release of the Kotlin plugin (1.2.71-release-IJ2018.2-1). The following code works fine if executed in a…
Tagc
  • 8,736
  • 7
  • 61
  • 114
0
votes
1 answer

How i can use sealed class as return type in Retrofit2

My sealed class sealed class TranslationResponse data class Success(val code: Int, val text: List) : TranslationResponse() data class Error(val code: Int, val message: String) : TranslationResponse() Retrofit2 request @POST("/.....") fun…
Danil
  • 165
  • 7
-1
votes
1 answer

How to call .value on a member of sealed class

in the below code i want to develop an example i saw on the google. but when i try to call .value it is never recognised nor defined in android studio. please have a look and let me know how to fix this issue class MainActivity :…
Amr Bakri
  • 11
  • 1
  • 3
-1
votes
1 answer

How to access inner data classes of sealed class from a recyclerView adapter

I'm having trouble setting up my ViewModel data for a chat interface i am building, I have a wide range of different types of data i want to show in a chat layout (RecyclerView). These include: Text,Buttons,Card view carousel... I have set up a…
Tristan O'Keefe
  • 371
  • 2
  • 4
  • 14
-8
votes
1 answer

Can a Java enum implement a sealed interface?

Can a Java enum implement a sealed interface in Java and why? A sealed subclass must be final, sealed or non-sealed. My reasoning is that if an enum could implement a sealed interface it can only be non-sealed, because it cannot be marked final and…
Naruga
  • 1
  • 1
1 2 3
9
10