-
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
86 additions
and
63 deletions.
There are no files selected for viewing
23 changes: 19 additions & 4 deletions
23
...ions-codegen/src/main/java/com/ramcosta/composedestinations/codegen/model/DefaultValue.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,21 @@ | ||
package com.ramcosta.composedestinations.codegen.model | ||
|
||
data class DefaultValue( | ||
val code: String, | ||
val imports: List<String> = emptyList() | ||
) | ||
import com.ramcosta.composedestinations.codegen.commons.IllegalDestinationsSetup | ||
|
||
sealed interface DefaultValue { | ||
|
||
data class Error(val throwable: Throwable) : DefaultValue | ||
|
||
data object NonExistent: DefaultValue | ||
|
||
data class Available( | ||
val code: String, | ||
val imports: List<String> = emptyList() | ||
) : DefaultValue | ||
} | ||
|
||
fun DefaultValue.unwrapAvailable(): DefaultValue.Available? = when (this) { | ||
is DefaultValue.Available -> this | ||
is DefaultValue.Error -> throw IllegalDestinationsSetup("Error reading default value", throwable) | ||
is DefaultValue.NonExistent -> null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.