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.IFeatureDefinitionInstanceInlined;
10 import gov.nist.secauto.metaschema.core.model.IFlagInstance;
11 import gov.nist.secauto.metaschema.core.util.ObjectUtils;
12 import gov.nist.secauto.metaschema.databind.io.BindingException;
13 import gov.nist.secauto.metaschema.databind.model.impl.InstanceFlagInline;
14 import gov.nist.secauto.metaschema.databind.model.info.IFeatureScalarItemValueHandler;
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 javax.xml.namespace.QName;
22
23 import edu.umd.cs.findbugs.annotations.NonNull;
24
25
26
27
28 public interface IBoundInstanceFlag
29 extends IFlagInstance, IBoundDefinitionFlag,
30 IFeatureScalarItemValueHandler,
31 IBoundInstance<Object>,
32 IFeatureDefinitionInstanceInlined<IBoundDefinitionFlag, IBoundInstanceFlag> {
33
34
35
36
37
38
39
40
41
42
43 @NonNull
44 static IBoundInstanceFlag newInstance(
45 @NonNull Field field,
46 @NonNull IBoundDefinitionModel<IBoundObject> containingDefinition) {
47 return new InstanceFlagInline(field, containingDefinition);
48 }
49
50
51
52
53
54
55
56
57
58 boolean isJsonKey();
59
60
61
62
63
64
65
66
67
68 boolean isJsonValueKey();
69
70
71
72
73 @Override
74 @NonNull
75 IBoundDefinitionModel<IBoundObject> getContainingDefinition();
76
77 @Override
78 @NonNull
79 default IBoundDefinitionModel<IBoundObject> getParentContainer() {
80 return getContainingDefinition();
81 }
82
83
84
85
86
87
88 @Override
89 @NonNull
90 IBoundDefinitionFlag getDefinition();
91
92 @Override
93 @NonNull
94 default IBoundInstanceFlag getInlineInstance() {
95
96 return this;
97 }
98
99 @Override
100 default void deepCopy(@NonNull IBoundObject fromInstance, @NonNull IBoundObject toInstance) throws BindingException {
101 Object value = getValue(fromInstance);
102 if (value != null) {
103 setValue(toInstance, deepCopyItem(value, toInstance));
104 }
105 }
106
107 @Override
108 @NonNull
109 default Object readItem(IBoundObject parent, @NonNull IItemReadHandler handler) throws IOException {
110 return handler.readItemFlag(ObjectUtils.requireNonNull(parent, "parent"), this);
111 }
112
113 @Override
114 default void writeItem(Object item, IItemWriteHandler handler) throws IOException {
115 handler.writeItemFlag(item, this);
116 }
117
118 @Override
119 default boolean canHandleXmlQName(@NonNull QName qname) {
120 return qname.equals(getXmlQName());
121 }
122 }