Currently for unions (and I guess for enums as well) the codegen generates sealed interface with all variants as sub-classes (records) implementing this sealed interface, which makes the use of such unions type-safe so that's amazing! But what I found a bit interesting is that at least for unions, there is also a private class being created, that is not used anywhere, but it blocks the usage of switch/case on type because the class is hidden and it is not possible to use it in case clause. Can you elaborate what is the purpose of this $Hidden class being generated but not accessible?
Basically for the following smithy model:
structure Payload {
testUnion: TestUnion
}
union TestUnion {
first: FirstStruct
second: SecondStruct
third: ThirdStruct
}
and the java code:
switch (input.getPayload().getTestUnion()) {
case FirstMember fm -> fm.first();
case SecondMember sm -> sm.second();
case ThirdMember tm -> tm.third();
case $Unknown unknown -> {
}
}
I'm getting switch' statement does not cover all possible input values error because I didn't cover $Hidden case 🙁
Currently for unions (and I guess for enums as well) the codegen generates sealed interface with all variants as sub-classes (records) implementing this sealed interface, which makes the use of such unions type-safe so that's amazing! But what I found a bit interesting is that at least for unions, there is also a private class being created, that is not used anywhere, but it blocks the usage of switch/case on type because the class is hidden and it is not possible to use it in
caseclause. Can you elaborate what is the purpose of this$Hiddenclass being generated but not accessible?Basically for the following smithy model:
and the java code:
I'm getting
switch' statement does not cover all possible input valueserror because I didn't cover$Hiddencase 🙁