1
2
3
4
5
6 package gov.nist.secauto.metaschema.core.model;
7
8 import gov.nist.secauto.metaschema.core.util.ObjectUtils;
9
10 import edu.umd.cs.findbugs.annotations.NonNull;
11 import edu.umd.cs.findbugs.annotations.Nullable;
12
13
14
15
16
17
18
19
20 public interface INamedModelInstanceAbsolute extends INamedModelInstance, IModelInstanceAbsolute, IJsonInstance {
21 @Override
22 default String getJsonName() {
23 @NonNull
24 String retval;
25 if (getMaxOccurs() == -1 || getMaxOccurs() > 1) {
26 @NonNull
27 String groupAsName = ObjectUtils.requireNonNull(getGroupAsName(),
28 ObjectUtils.notNull(String.format("null group-as name in instance '%s' on definition '%s' in '%s'",
29 this.getName(),
30 this.getContainingDefinition().getName(),
31 this.getContainingModule().getLocation())));
32 retval = groupAsName;
33 } else {
34 retval = getEffectiveName();
35 }
36 return retval;
37 }
38
39 @Override
40 @Nullable
41 default IFlagInstance getEffectiveJsonKey() {
42 return getJsonGroupAsBehavior() == JsonGroupAsBehavior.KEYED
43 ? getJsonKey()
44 : null;
45 }
46
47 @Override
48 @Nullable
49 default IFlagInstance getJsonKey() {
50 return getDefinition().getJsonKey();
51 }
52 }