1
2
3
4
5
6 package gov.nist.secauto.metaschema.databind.model;
7
8 import gov.nist.secauto.metaschema.core.model.IBoundObject;
9 import gov.nist.secauto.metaschema.core.model.IChoiceGroupInstance;
10 import gov.nist.secauto.metaschema.core.model.IFeatureContainerModelGrouped;
11 import gov.nist.secauto.metaschema.core.qname.IEnhancedQName;
12 import gov.nist.secauto.metaschema.core.util.ObjectUtils;
13 import gov.nist.secauto.metaschema.databind.io.BindingException;
14 import gov.nist.secauto.metaschema.databind.model.impl.InstanceModelChoiceGroup;
15 import gov.nist.secauto.metaschema.databind.model.info.IItemReadHandler;
16 import gov.nist.secauto.metaschema.databind.model.info.IItemWriteHandler;
17
18 import java.io.IOException;
19 import java.lang.reflect.Field;
20
21 import edu.umd.cs.findbugs.annotations.NonNull;
22 import edu.umd.cs.findbugs.annotations.Nullable;
23
24
25
26
27 public interface IBoundInstanceModelChoiceGroup
28 extends IBoundInstanceModel<IBoundObject>, IFeatureContainerModelGrouped<
29 IBoundInstanceModelGroupedNamed,
30 IBoundInstanceModelGroupedField,
31 IBoundInstanceModelGroupedAssembly>,
32 IChoiceGroupInstance {
33
34
35
36
37
38
39
40
41
42
43 @NonNull
44 static IBoundInstanceModelChoiceGroup newInstance(
45 @NonNull Field field,
46 @NonNull IBoundDefinitionModelAssembly containingDefinition) {
47 return InstanceModelChoiceGroup.newInstance(field, containingDefinition);
48 }
49
50 @Override
51 default String getJsonName() {
52
53 return ObjectUtils.requireNonNull(getGroupAsName());
54 }
55
56 @Override
57 @NonNull
58 IBoundDefinitionModelAssembly getOwningDefinition();
59
60 @Override
61 default IBoundDefinitionModelAssembly getContainingDefinition() {
62 return getOwningDefinition();
63 }
64
65
66
67
68
69
70
71
72
73 @Nullable
74 IBoundInstanceModelGroupedNamed getGroupedModelInstance(@NonNull Class<?> clazz);
75
76
77
78
79
80
81
82
83
84
85
86 @Nullable
87 IBoundInstanceModelGroupedNamed getGroupedModelInstance(@NonNull IEnhancedQName name);
88
89
90
91
92
93
94
95
96
97
98
99 @Nullable
100 IBoundInstanceModelGroupedNamed getGroupedModelInstance(@NonNull String discriminator);
101
102
103
104
105
106
107
108
109
110 @Override
111 @NonNull
112 default IBoundInstanceModelGroupedNamed getItemInstance(Object item) {
113 return ObjectUtils.requireNonNull(getGroupedModelInstance(item.getClass()));
114 }
115
116 @Override
117 default IBoundObject readItem(IBoundObject parent, IItemReadHandler handler) throws IOException {
118 return handler.readChoiceGroupItem(ObjectUtils.requireNonNull(parent, "parent"), this);
119 }
120
121 @Override
122 default void writeItem(IBoundObject item, IItemWriteHandler handler) throws IOException {
123 handler.writeChoiceGroupItem(item, this);
124 }
125
126 @Override
127 default IBoundObject deepCopyItem(IBoundObject item, IBoundObject parentInstance) throws BindingException {
128 IBoundInstanceModelGroupedNamed itemInstance = getItemInstance(item);
129 return itemInstance.deepCopyItem(item, parentInstance);
130 }
131
132 @Override
133 default boolean canHandleXmlQName(@NonNull IEnhancedQName qname) {
134 return getGroupedModelInstance(qname) != null;
135 }
136 }