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