part5polymorphic: add F05-F08 (default typing modes, type validation, sealed hierarchies, unknown subtypes) for the rewritten polymorphism post (#59)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JXVi2GMQ7bR5EmbUFdDj7N
This commit is contained in:
Claude
2026-10-09 10:35:38 +00:00
parent 84070a8dfb
commit b1663c235d
9 changed files with 277 additions and 3 deletions
+19
View File
@@ -0,0 +1,19 @@
NONE (no default typing): {"any":{"label":"t"},"colour":"RED","dot":{"x":2},"items":["a"],"numbers":[1,2],"shape":{"x":1},"tag":{"label":"t"},"text":"s"}
JAVA_LANG_OBJECT:
{"any":["~Tag",{"label":"t"}],"colour":"RED","dot":{"x":2},"items":["a"],"numbers":[1,2],"shape":{"x":1},"tag":{"label":"t"},"text":"s"}
OBJECT_AND_NON_CONCRETE:
{"any":["~Tag",{"label":"t"}],"colour":"RED","dot":{"x":2},"items":["java.util.ImmutableCollections$List12",["a"]],"numbers":[1,2],"shape":["~Dot",{"x":1}],"tag":{"label":"t"},"text":"s"}
NON_CONCRETE_AND_ARRAYS:
{"any":["~Tag",{"label":"t"}],"colour":"RED","dot":{"x":2},"items":["java.util.ImmutableCollections$List12",["a"]],"numbers":[1,2],"shape":["~Dot",{"x":1}],"tag":{"label":"t"},"text":"s"}
NON_FINAL:
["~Holder",{"any":["~Tag",{"label":"t"}],"colour":"RED","dot":{"x":2},"items":["java.util.ImmutableCollections$List12",["a"]],"numbers":[1,2],"shape":["~Dot",{"x":1}],"tag":{"label":"t"},"text":"s"}]
NON_FINAL_AND_ENUMS:
["~Holder",{"any":["~Tag",{"label":"t"}],"colour":["~Colour","RED"],"dot":{"x":2},"items":["java.util.ImmutableCollections$List12",["a"]],"numbers":[1,2],"shape":["~Dot",{"x":1}],"tag":{"label":"t"},"text":"s"}]
NON_FINAL_AND_RECORDS:
["~Holder",{"any":["~Tag",{"label":"t"}],"colour":"RED","dot":["~Dot",{"x":2}],"items":["java.util.ImmutableCollections$List12",["a"]],"numbers":[1,2],"shape":["~Dot",{"x":1}],"tag":{"label":"t"},"text":"s"}]
+6
View File
@@ -0,0 +1,6 @@
default mapper, Good (listed in @JsonSubTypes) -> accepted Good
default mapper, Rogue (not listed) -> accepted Rogue
FAIL_ON_SUBTYPE_CLASS_NOT_REGISTERED, Good -> accepted Good
FAIL_ON_SUBTYPE_CLASS_NOT_REGISTERED, Rogue -> InvalidTypeIdException
PolymorphicTypeValidator allowing only Good, Good -> accepted Good
PolymorphicTypeValidator allowing only Good, Rogue -> InvalidTypeIdException
+11
View File
@@ -0,0 +1,11 @@
each as Event.class:
{"kind":"payment","id":"p1","amount":10.0}
{"kind":"refund","id":"r1","amount":4.0}
{"kind":"login","user":"ann"}
{"kind":"F07SealedHierarchies$Logout","user":"ann"}
round trip equal: true
payment 10.0
refund 4.0
login ann
logout ann
nested sealed type read as Audit.class: Login[user=bo]
+7
View File
@@ -0,0 +1,7 @@
defaultImpl, known name -> Click[x=3]
defaultImpl, unknown name 'swipe' -> Unknown[]
defaultImpl, class-name attack -> Unknown[]
defaultImpl, discriminator missing -> Unknown[]
FAIL_ON_INVALID_SUBTYPE off, unknown name -> null
FAIL_ON_INVALID_SUBTYPE off, missing discriminator -> null
default, unknown name -> InvalidTypeIdException