-
Notifications
You must be signed in to change notification settings - Fork 6
/
Cardinality.sadl
263 lines (225 loc) · 7.6 KB
/
Cardinality.sadl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
uri "http://Cardinality" alias card.
Value is a class.
val1 is a Value.
val2 is a Value.
// =====================================================================================
// test cardinality of data and object properties
Cardinal is a class,
described by anyData with values of type int,
described by anyObject with values of type Value,
described by singleData with a single value of type int,
described by singleObject with a single value of type Value,
described by exactly1Data with values of type int,
described by exactly1Object with values of type Value,
described by atLeast1Data with values of type int,
described by atLeast1Object with values of type Value,
described by atMost1Data with values of type int,
described by atMost1Object with values of type Value,
described by range12Data with values of type int,
described by range12Object with values of type Value.
// Note: SADL Feature 3.5.0.202112051741
// throws errors if these restrictions are attempted inline above.
exactly1Data of Cardinal has exactly 1 value.
exactly1Object of Cardinal has exactly 1 value.
atLeast1Data of Cardinal has at least 1 value.
atLeast1Object of Cardinal has at least 1 value.
atMost1Data of Cardinal has at most 1 value.
atMost1Object of Cardinal has at most 1 value.
range12Data of Cardinal has at least 1 value.
range12Data of Cardinal has at most 2 values.
range12Object of Cardinal has at least 1 value.
range12Object of Cardinal has at most 2 values.
card0 (note "instance with no properties") is a Cardinal.
// 6 errors for the "exactly 1" properties since there are none.
card1 (note "instance with one of each property") is a Cardinal,
has anyData 1,
has anyObject val1,
has singleData 1,
has singleObject val1,
has exactly1Data 1,
has exactly1Object val1,
has atLeast1Data 1,
has atLeast1Object val1,
has atMost1Data 1,
has atMost1Object val1,
has range12Data 1,
has range12Object val1.
card2 (note "instance with two of each property") is a Cardinal,
has anyData 1,
has anyObject val1,
has singleData 1,
has singleObject val1,
has exactly1Data 1,
has exactly1Object val1,
has atLeast1Data 1,
has atLeast1Object val1,
has atMost1Data 1,
has atMost1Object val1,
has range12Data 1,
has range12Object val1,
has anyData 2,
has anyObject val2,
has singleData 2,
has singleObject val2,
has exactly1Data 2,
has exactly1Object val2,
has atLeast1Data 2,
has atLeast1Object val2,
has atMost1Data 2,
has atMost1Object val2,
has range12Data 2,
has range12Object val2.
// =====================================================================================
// Repeat with all the same properties but no restrictions on their use in this class
UnrestrictedCardinal is a class,
described by anyData with values of type int,
described by anyObject with values of type Value,
described by singleData with values of type int,
described by singleObject with values of type Value,
described by exactly1Data with values of type int,
described by exactly1Object with values of type Value,
described by atLeast1Data with values of type int,
described by atLeast1Object with values of type Value,
described by atMost1Data with values of type int,
described by atMost1Object with values of type Value,
described by range12Data with values of type int,
described by range12Object with values of type Value.
unrest0 (note "instance with no properties") is a UnrestrictedCardinal.
unrest1 (note "instance with one of each property") is a UnrestrictedCardinal,
has anyData 1,
has anyObject val1,
has singleData 1,
has singleObject val1,
has exactly1Data 1,
has exactly1Object val1,
has atLeast1Data 1,
has atLeast1Object val1,
has atMost1Data 1,
has atMost1Object val1,
has range12Data 1,
has range12Object val1.
unrest2 (note "instance with two of each property") is a UnrestrictedCardinal,
has anyData 1,
has anyObject val1,
has singleData 1,
has singleObject val1,
has exactly1Data 1,
has exactly1Object val1,
has atLeast1Data 1,
has atLeast1Object val1,
has atMost1Data 1,
has atMost1Object val1,
has range12Data 1,
has range12Object val1,
has anyData 2,
has anyObject val2,
has singleData 2,
has singleObject val2,
has exactly1Data 2,
has exactly1Object val2,
has atLeast1Data 2,
has atLeast1Object val2,
has atMost1Data 2,
has atMost1Object val2,
has range12Data 2,
has range12Object val2.
// =====================================================================================
// Repeat for a subclass
SubCardinal is a type of Cardinal.
sub0 (note "instance with no properties") is a SubCardinal.
// 6 errors for the "exactly 1" properties since there are none.
sub1 (note "instance with one of each property") is a SubCardinal,
has anyData 1,
has anyObject val1,
has singleData 1,
has singleObject val1,
has exactly1Data 1,
has exactly1Object val1,
has atLeast1Data 1,
has atLeast1Object val1,
has atMost1Data 1,
has atMost1Object val1,
has range12Data 1,
has range12Object val1.
sub2 (note "instance with two of each property") is a SubCardinal,
has anyData 1,
has anyObject val1,
has singleData 1,
has singleObject val1,
has exactly1Data 1,
has exactly1Object val1,
has atLeast1Data 1,
has atLeast1Object val1,
has atMost1Data 1,
has atMost1Object val1,
has range12Data 1,
has range12Object val1,
has anyData 2,
has anyObject val2,
has singleData 2,
has singleObject val2,
has exactly1Data 2,
has exactly1Object val2,
has atLeast1Data 2,
has atLeast1Object val2,
has atMost1Data 2,
has atMost1Object val2,
has range12Data 2,
has range12Object val2.
// =====================================================================================
// Add restrictions to a subclass
RestrictTheUnrestricted is a type of UnrestrictedCardinal.
// Note: SADL Feature 3.5.0.202112051741
// these two generate syntax error. Can't figure out how to test.
//singleData of RestrictTheUnrestricted has a single value.
//singleObject of RestrictTheUnrestricted has a single value.
// copy the restrictions from Cardinal
exactly1Data of RestrictTheUnrestricted has exactly 1 value.
exactly1Object of RestrictTheUnrestricted has exactly 1 value.
atLeast1Data of RestrictTheUnrestricted has at least 1 value.
atLeast1Object of RestrictTheUnrestricted has at least 1 value.
atMost1Data of RestrictTheUnrestricted has at most 1 value.
atMost1Object of RestrictTheUnrestricted has at most 1 value.
range12Data of RestrictTheUnrestricted has at least 1 value.
range12Data of RestrictTheUnrestricted has at most 2 values.
range12Object of RestrictTheUnrestricted has at least 1 value.
range12Object of RestrictTheUnrestricted has at most 2 values.
rtu0 (note "instance with no properties") is a RestrictTheUnrestricted.
rtu1 (note "instance with one of each property") is a RestrictTheUnrestricted,
has anyData 1,
has anyObject val1,
has singleData 1,
has singleObject val1,
has exactly1Data 1,
has exactly1Object val1,
has atLeast1Data 1,
has atLeast1Object val1,
has atMost1Data 1,
has atMost1Object val1,
has range12Data 1,
has range12Object val1.
rtu2 (note "instance with two of each property") is a RestrictTheUnrestricted,
has anyData 1,
has anyObject val1,
has singleData 1,
has singleObject val1,
has exactly1Data 1,
has exactly1Object val1,
has atLeast1Data 1,
has atLeast1Object val1,
has atMost1Data 1,
has atMost1Object val1,
has range12Data 1,
has range12Object val1,
has anyData 2,
has anyObject val2,
has singleData 2,
has singleObject val2,
has exactly1Data 2,
has exactly1Object val2,
has atLeast1Data 2,
has atLeast1Object val2,
has atMost1Data 2,
has atMost1Object val2,
has range12Data 2,
has range12Object val2.