1 /*
2 * SPDX-FileCopyrightText: none
3 * SPDX-License-Identifier: CC0-1.0
4 */
5
6 package dev.metaschema.schemagen;
7
8 import dev.metaschema.core.model.IChoiceInstance;
9 import dev.metaschema.core.model.IDefinition;
10
11 /**
12 * An inline strategy that inlines definitions unless they are contained within
13 * a choice block.
14 * <p>
15 * Definitions that are part of a choice block are not inlined to ensure proper
16 * schema generation for mutually exclusive alternatives.
17 */
18 public class ChoiceNotInlineStrategy implements IInlineStrategy {
19 @Override
20 public boolean isInline(
21 IDefinition definition,
22 ModuleIndex metaschemaIndex) {
23 // allow inline if the definition is inline and not part of definition with a
24 // choice
25 return definition.isInline() && !(definition.getInlineInstance().getParentContainer() instanceof IChoiceInstance);
26 }
27 }