001/* 002 * SPDX-FileCopyrightText: none 003 * SPDX-License-Identifier: CC0-1.0 004 */ 005 006package dev.metaschema.schemagen; 007 008import dev.metaschema.core.model.IChoiceInstance; 009import dev.metaschema.core.model.IDefinition; 010 011/** 012 * An inline strategy that inlines definitions unless they are contained within 013 * a choice block. 014 * <p> 015 * Definitions that are part of a choice block are not inlined to ensure proper 016 * schema generation for mutually exclusive alternatives. 017 */ 018public class ChoiceNotInlineStrategy implements IInlineStrategy { 019 @Override 020 public boolean isInline( 021 IDefinition definition, 022 ModuleIndex metaschemaIndex) { 023 // allow inline if the definition is inline and not part of definition with a 024 // choice 025 return definition.isInline() && !(definition.getInlineInstance().getParentContainer() instanceof IChoiceInstance); 026 } 027}