1
2
3
4
5
6 package gov.nist.secauto.metaschema.schemagen;
7
8 import gov.nist.secauto.metaschema.core.configuration.IConfiguration;
9 import gov.nist.secauto.metaschema.core.model.IDefinition;
10
11 import edu.umd.cs.findbugs.annotations.NonNull;
12
13 public interface IInlineStrategy {
14 @NonNull
15 IInlineStrategy NONE_INLINE = new IInlineStrategy() {
16 @Override
17 public boolean isInline(
18 @NonNull IDefinition definition,
19 @NonNull ModuleIndex metaschemaIndex) {
20 return false;
21 }
22 };
23
24 @NonNull
25 IInlineStrategy DEFINED_AS_INLINE = new IInlineStrategy() {
26 @Override
27 public boolean isInline(
28 @NonNull IDefinition definition,
29 @NonNull ModuleIndex metaschemaIndex) {
30 return definition.isInline();
31 }
32 };
33
34 @NonNull
35 IInlineStrategy CHOICE_NOT_INLINE = new ChoiceNotInlineStrategy();
36
37 @NonNull
38 static IInlineStrategy newInlineStrategy(@NonNull IConfiguration<SchemaGenerationFeature<?>> configuration) {
39 IInlineStrategy retval;
40 if (configuration.isFeatureEnabled(SchemaGenerationFeature.INLINE_DEFINITIONS)) {
41 if (configuration.isFeatureEnabled(SchemaGenerationFeature.INLINE_CHOICE_DEFINITIONS)) {
42 retval = DEFINED_AS_INLINE;
43 } else {
44 retval = CHOICE_NOT_INLINE;
45 }
46 } else {
47 retval = NONE_INLINE;
48 }
49 return retval;
50 }
51
52 boolean isInline(
53 @NonNull IDefinition definition,
54 @NonNull ModuleIndex metaschemaIndex);
55 }