use of org.opendaylight.yangtools.yang.model.api.ContainerLike in project mdsal by opendaylight.
the class DataObjectStreamerGenerator method generateStreamer.
static Class<? extends DataObjectStreamer<?>> generateStreamer(final CodecClassLoader loader, final CodecContextFactory registry, final Class<?> type) {
final var typeAndSchema = registry.getRuntimeContext().getTypeWithSchema(type);
final var schema = typeAndSchema.statement();
final StackManipulation startEvent;
if (schema instanceof ContainerLike || schema instanceof NotificationDefinition) {
startEvent = classUnknownSizeMethod(START_CONTAINER_NODE, type);
} else if (schema instanceof ListSchemaNode) {
startEvent = ((ListSchemaNode) schema).getKeyDefinition().isEmpty() ? START_UNKEYED_LIST_ITEM : START_MAP_ENTRY_NODE;
} else if (schema instanceof AugmentationSchemaNode) {
// startAugmentationNode(Foo.class)
startEvent = new StackManipulation.Compound(ClassConstant.of(Sort.describe(type).asErasure()), START_AUGMENTATION_NODE);
} else if (schema instanceof CaseSchemaNode) {
startEvent = classUnknownSizeMethod(START_CASE, type);
} else {
throw new UnsupportedOperationException("Schema type " + schema.getClass() + " is not supported");
}
return loader.generateClass(type, "streamer", // FIXME: cast to GeneratedType: we really should adjust getTypeWithSchema()
new DataObjectStreamerGenerator<>(registry, (GeneratedType) typeAndSchema.javaType(), (DataNodeContainer) schema, type, startEvent));
}
Aggregations