1
2
3
4
5
6 package gov.nist.secauto.metaschema.core.model;
7
8 import gov.nist.secauto.metaschema.core.model.constraint.IFeatureValueConstrained;
9
10 import java.util.Locale;
11
12 import javax.xml.namespace.QName;
13
14 import edu.umd.cs.findbugs.annotations.NonNull;
15 import edu.umd.cs.findbugs.annotations.Nullable;
16
17 public interface IDefinition extends INamedModelElement, IAttributable, IFeatureValueConstrained {
18
19 @NonNull
20 ModuleScopeEnum DEFAULT_DEFINITION_MODEL_SCOPE = ModuleScopeEnum.INHERITED;
21
22
23
24
25
26
27 @NonNull
28 default ModuleScopeEnum getModuleScope() {
29 return ModuleScopeEnum.LOCAL;
30 }
31
32
33
34
35
36
37
38
39
40 @NonNull
41 default QName getDefinitionQName() {
42 return new QName(
43 getContainingModule().getXmlNamespace().toASCIIString(),
44 getName());
45 }
46
47
48
49
50
51
52
53
54 default boolean isInline() {
55 return getInlineInstance() != null;
56 }
57
58
59
60
61
62
63
64 INamedInstance getInlineInstance();
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80 @SuppressWarnings("null")
81 @Override
82 default String toCoordinates() {
83 return String.format("%s:%s-definition:%s(%d)",
84 getContainingModule().getShortName(),
85 getModelType().toString().toUpperCase(Locale.ROOT),
86 getName(),
87 hashCode());
88 }
89
90
91
92
93
94
95
96
97
98 @Nullable
99 default IResourceLocation getLocation(@NonNull Object itemValue) {
100 return itemValue instanceof IBoundObject ? ((IBoundObject) itemValue).getMetaschemaData() : null;
101 }
102 }