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 public interface INamedModelInstanceAbsolute extends INamedModelInstance, IModelInstanceAbsolute, IJsonInstance {
14 @Override
15 default String getJsonName() {
16 @NonNull
17 String retval;
18 if (getMaxOccurs() == -1 || getMaxOccurs() > 1) {
19 @NonNull
20 String groupAsName = ObjectUtils.requireNonNull(getGroupAsName(),
21 ObjectUtils.notNull(String.format("null group-as name in instance '%s' on definition '%s' in '%s'",
22 this.getName(),
23 this.getContainingDefinition().getName(),
24 this.getContainingModule().getLocation())));
25 retval = groupAsName;
26 } else {
27 retval = getEffectiveName();
28 }
29 return retval;
30 }
31
32 @Override
33 @Nullable
34 default IFlagInstance getEffectiveJsonKey() {
35 return JsonGroupAsBehavior.KEYED.equals(getJsonGroupAsBehavior())
36 ? getJsonKey()
37 : null;
38 }
39
40 @Override
41 @Nullable
42 default IFlagInstance getJsonKey() {
43 return getDefinition().getJsonKey();
44 }
45 }