1
2
3
4
5
6 package gov.nist.secauto.metaschema.core.model;
7
8 import gov.nist.secauto.metaschema.core.model.util.ModuleUtils;
9 import gov.nist.secauto.metaschema.core.util.ObjectUtils;
10
11 import edu.umd.cs.findbugs.annotations.NonNull;
12 import edu.umd.cs.findbugs.annotations.Nullable;
13
14
15
16
17 public interface INamedModelInstanceGrouped extends INamedModelInstance {
18 @Override
19 IChoiceGroupInstance getParentContainer();
20
21 @Override
22 default IAssemblyDefinition getContainingDefinition() {
23 return getParentContainer().getContainingDefinition();
24 }
25
26
27
28
29
30
31
32
33 @Nullable
34 String getDiscriminatorValue();
35
36
37
38
39
40
41
42 @NonNull
43 default String getEffectiveDisciminatorValue() {
44 String retval = getDiscriminatorValue();
45 if (retval == null) {
46 retval = getEffectiveName();
47 }
48 return retval;
49 }
50
51 @Override
52 @Nullable
53 default IFlagInstance getEffectiveJsonKey() {
54 return JsonGroupAsBehavior.KEYED.equals(getParentContainer().getJsonGroupAsBehavior())
55 ? ObjectUtils.requireNonNull(getJsonKey())
56 : null;
57 }
58
59 @Override
60 @Nullable
61 default IFlagInstance getJsonKey() {
62 String name = getParentContainer().getJsonKeyFlagInstanceName();
63 return name == null
64 ? null
65 : ObjectUtils.requireNonNull(
66 getDefinition().getFlagInstanceByName(
67 ModuleUtils.parseFlagName(getContainingModule(), name).getIndexPosition()));
68 }
69
70 @Override
71 default int getMinOccurs() {
72 return getParentContainer().getMinOccurs();
73 }
74
75 @Override
76 default int getMaxOccurs() {
77 return getParentContainer().getMaxOccurs();
78 }
79
80 }