001/*
002 * SPDX-FileCopyrightText: none
003 * SPDX-License-Identifier: CC0-1.0
004 */
005
006package gov.nist.secauto.metaschema.schemagen;
007
008import gov.nist.secauto.metaschema.core.configuration.IConfiguration;
009import gov.nist.secauto.metaschema.core.model.IDefinition;
010
011import edu.umd.cs.findbugs.annotations.NonNull;
012
013public interface IInlineStrategy {
014  @NonNull
015  IInlineStrategy NONE_INLINE = new IInlineStrategy() {
016    @Override
017    public boolean isInline(
018        @NonNull IDefinition definition,
019        @NonNull ModuleIndex metaschemaIndex) {
020      return false;
021    }
022  };
023
024  @NonNull
025  IInlineStrategy DEFINED_AS_INLINE = new IInlineStrategy() {
026    @Override
027    public boolean isInline(
028        @NonNull IDefinition definition,
029        @NonNull ModuleIndex metaschemaIndex) {
030      return definition.isInline();
031    }
032  };
033
034  @NonNull
035  IInlineStrategy CHOICE_NOT_INLINE = new ChoiceNotInlineStrategy();
036
037  @NonNull
038  static IInlineStrategy newInlineStrategy(@NonNull IConfiguration<SchemaGenerationFeature<?>> configuration) {
039    IInlineStrategy retval;
040    if (configuration.isFeatureEnabled(SchemaGenerationFeature.INLINE_DEFINITIONS)) {
041      if (configuration.isFeatureEnabled(SchemaGenerationFeature.INLINE_CHOICE_DEFINITIONS)) {
042        retval = DEFINED_AS_INLINE;
043      } else {
044        retval = CHOICE_NOT_INLINE;
045      }
046    } else {
047      retval = NONE_INLINE;
048    }
049    return retval;
050  }
051
052  boolean isInline(
053      @NonNull IDefinition definition,
054      @NonNull ModuleIndex metaschemaIndex);
055}