-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from MercuryTechnologies/tad/sealed-interface
Kotlin: Generate sealed interfaces for tagged objects
- Loading branch information
Showing
9 changed files
with
22 additions
and
24 deletions.
There are no files selected for viewing
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,16 +1,16 @@ | ||
/** Top-level documentation describing [Enum]. */ | ||
@JsonClassDiscriminator("tag") | ||
@Serializable | ||
sealed class Enum : Parcelable { | ||
sealed interface Enum : Parcelable { | ||
/** A constructor. */ | ||
@Parcelize | ||
@Serializable | ||
@SerialName("dataCons0") | ||
data class DataCons0(val contents: Record0) : Enum() | ||
data class DataCons0(val contents: Record0) : Enum | ||
|
||
/** Another constructor. */ | ||
@Parcelize | ||
@Serializable | ||
@SerialName("dataCons1") | ||
data class DataCons1(val contents: Record1) : Enum() | ||
data class DataCons1(val contents: Record1) : Enum | ||
} |
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,2 +1,2 @@ | ||
@Serializable | ||
sealed class Enum : Parcelable | ||
sealed interface Enum : Parcelable |
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,2 +1,2 @@ | ||
@Serializable(with = Enum1Serializer::class) | ||
sealed class Enum : Parcelable | ||
sealed interface Enum : Parcelable |
2 changes: 1 addition & 1 deletion
2
.golden/kotlinEnumSumOfProductWithTaggedFlatObjectStyleSpec/golden
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,2 +1,2 @@ | ||
@Serializable | ||
sealed class Enum : Parcelable | ||
sealed interface Enum : Parcelable |
6 changes: 3 additions & 3 deletions
6
.golden/kotlinEnumSumOfProductWithTaggedObjectAndNonConcreteCasesSpec/golden
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,13 +1,13 @@ | ||
@JsonClassDiscriminator("tag") | ||
@Serializable | ||
sealed class Enum : Parcelable { | ||
sealed interface Enum : Parcelable { | ||
@Parcelize | ||
@Serializable | ||
@SerialName("dataCons0") | ||
data class DataCons0(val contents: List<Record0>) : Enum() | ||
data class DataCons0(val contents: List<Record0>) : Enum | ||
|
||
@Parcelize | ||
@Serializable | ||
@SerialName("dataCons1") | ||
data class DataCons1(val contents: List<Record1>) : Enum() | ||
data class DataCons1(val contents: List<Record1>) : Enum | ||
} |
6 changes: 3 additions & 3 deletions
6
.golden/kotlinEnumSumOfProductWithTaggedObjectAndSingleNullarySpec/golden
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,13 +1,13 @@ | ||
@JsonClassDiscriminator("tag") | ||
@Serializable | ||
sealed class Enum : Parcelable { | ||
sealed interface Enum : Parcelable { | ||
@Parcelize | ||
@Serializable | ||
@SerialName("dataCons0") | ||
data class DataCons0(val contents: Record0) : Enum() | ||
data class DataCons0(val contents: Record0) : Enum | ||
|
||
@Parcelize | ||
@Serializable | ||
@SerialName("dataCons1") | ||
data object DataCons1 : Enum() | ||
data object DataCons1 : Enum | ||
} |
8 changes: 4 additions & 4 deletions
8
.golden/kotlinEnumSumOfProductWithTaggedObjectStyleSpec/golden
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,18 +1,18 @@ | ||
@JsonClassDiscriminator("tag") | ||
@Serializable | ||
sealed class Enum : Parcelable { | ||
sealed interface Enum : Parcelable { | ||
@Parcelize | ||
@Serializable | ||
@SerialName("dataCons0") | ||
data class DataCons0(val contents: Record0) : Enum() | ||
data class DataCons0(val contents: Record0) : Enum | ||
|
||
@Parcelize | ||
@Serializable | ||
@SerialName("dataCons1") | ||
data class DataCons1(val contents: Record1) : Enum() | ||
data class DataCons1(val contents: Record1) : Enum | ||
|
||
@Parcelize | ||
@Serializable | ||
@SerialName("dataCons2") | ||
data object DataCons2 : Enum() | ||
data object DataCons2 : Enum | ||
} |
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,15 +1,15 @@ | ||
@JsonClassDiscriminator("direction") | ||
@Serializable | ||
sealed class CursorInput<A> { | ||
sealed interface CursorInput<A> { | ||
@Serializable | ||
@SerialName("nextPage") | ||
data class NextPage<A>(val key: A?) : CursorInput<A>() | ||
data class NextPage<A>(val key: A?) : CursorInput<A> | ||
|
||
@Serializable | ||
@SerialName("previousPage") | ||
data class PreviousPage<A>(val key: A) : CursorInput<A>() | ||
data class PreviousPage<A>(val key: A) : CursorInput<A> | ||
|
||
@Serializable | ||
@SerialName("unknown") | ||
data object Unknown : CursorInput<Nothing>() | ||
data object Unknown : CursorInput<Nothing> | ||
} |
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