- checkArgument(schemaNode instanceof LeafSchemaNode, "schemaNode must be of type LeafSchemaNode");
- final XmlCodec<?> objectXmlCodec = codecFactory.codecFor((LeafSchemaNode) schemaNode, resolver);
+ final XmlCodec<?> objectXmlCodec;
+ if (schemaNode instanceof LeafSchemaNode leafSchemaNode) {
+ objectXmlCodec = codecFactory.codecFor(leafSchemaNode, resolver);
+ } else if (schemaNode instanceof LeafListSchemaNode leafListSchemaNode) {
+ objectXmlCodec = codecFactory.codecFor(leafListSchemaNode, resolver);
+ } else {
+ throw new IllegalArgumentException("schemaNode " + schemaNode
+ + " must be of type LeafSchemaNode or LeafListSchemaNode");
+ }