1
2
3
4
5
6 package gov.nist.secauto.metaschema.databind.model.info;
7
8 import gov.nist.secauto.metaschema.core.model.IBoundObject;
9 import gov.nist.secauto.metaschema.databind.model.IBoundInstanceFlag;
10 import gov.nist.secauto.metaschema.databind.model.IBoundInstanceModel;
11 import gov.nist.secauto.metaschema.databind.model.IBoundInstanceModelNamed;
12
13 import edu.umd.cs.findbugs.annotations.NonNull;
14
15 public abstract class AbstractModelInstanceReadHandler<ITEM> implements IModelInstanceReadHandler<ITEM> {
16 @NonNull
17 private final IBoundInstanceModel<ITEM> instance;
18 @NonNull
19 private final IBoundObject parentObject;
20
21 protected AbstractModelInstanceReadHandler(
22 @NonNull IBoundInstanceModel<ITEM> instance,
23 @NonNull IBoundObject parentObject) {
24 this.instance = instance;
25 this.parentObject = parentObject;
26 }
27
28
29
30
31
32
33 @NonNull
34 public IBoundInstanceModel<ITEM> getInstance() {
35 return instance;
36 }
37
38
39
40
41
42
43 @NonNull
44 public IModelInstanceCollectionInfo<ITEM> getCollectionInfo() {
45 return getInstance().getCollectionInfo();
46 }
47
48
49
50
51
52
53 @NonNull
54 public IBoundObject getParentObject() {
55 return parentObject;
56 }
57
58 @Override
59 public String getJsonKeyFlagName() {
60 IBoundInstanceModel<?> instance = getInstance();
61 String retval = null;
62 if (instance instanceof IBoundInstanceModelNamed) {
63 IBoundInstanceFlag jsonKey = ((IBoundInstanceModelNamed<?>) instance).getEffectiveJsonKey();
64 if (jsonKey != null) {
65 retval = jsonKey.getEffectiveName();
66 }
67 }
68 return retval;
69 }
70 }