@@ -182,7 +182,8 @@ function displayWarningIfMissingRequiredProps(obj)
182
182
183
183
propertyListStr = obj .prettyPrintPropertyList(missingRequiredProps );
184
184
warning(' NWB:RequiredPropertyMissing' , ...
185
- ' The following required properties are missing for instance for type "%s ":\n%s ' , class(obj ), propertyListStr )
185
+ [' The following required properties are missing for ' , ...
186
+ ' instance for type "%s ":\n%s ' ], class(obj ), propertyListStr )
186
187
end
187
188
end
188
189
@@ -202,7 +203,9 @@ function throwErrorIfMissingRequiredProps(obj, fullpath)
202
203
if ~isempty( missingRequiredProps )
203
204
propertyListStr = obj .prettyPrintPropertyList(missingRequiredProps );
204
205
error(' NWB:RequiredPropertyMissing' , ...
205
- ' The following required properties are missing for instance for type "%s " at file location "%s ":\n%s ' , class(obj ), fullpath , propertyListStr )
206
+ [' The following required properties are missing for ' , ...
207
+ ' instance for type "%s " at file location "%s ":\n%s ' ], ...
208
+ class(obj ), fullpath , propertyListStr )
206
209
end
207
210
end
208
211
@@ -211,7 +214,9 @@ function throwErrorIfCustomConstraintUnfulfilled(obj, fullpath)
211
214
obj .checkCustomConstraint()
212
215
catch ME
213
216
error(' NWB:CustomConstraintUnfulfilled' , ...
214
- ' The following error was caught when exporting type "%s " at file location "%s ":\n%s ' , class(obj ), fullpath , ME .message )
217
+ [' The following error was caught when exporting type ' , ...
218
+ ' "%s " at file location "%s ":\n%s ' ], ...
219
+ class(obj ), fullpath , ME .message )
215
220
end
216
221
end
217
222
end
@@ -227,16 +232,21 @@ function checkCustomConstraint(obj) %#ok<MANU>
227
232
function requiredProps = getRequiredProperties(obj )
228
233
229
234
% Introspectively retrieve required properties and add to
230
- % persistent map.
235
+ % persistent cache/ map.
231
236
232
- if isKey(obj .REQUIRED , class(obj ) )
233
- requiredProps = obj .REQUIRED( class(obj ) );
237
+ typeClassName = class(obj );
238
+ typeNamespaceVersion = getNamespaceVersionForType(typeClassName );
239
+
240
+ typeKey = sprintf(' %s _%s ' , typeClassName , typeNamespaceVersion );
241
+
242
+ if isKey(obj .REQUIRED , typeKey )
243
+ requiredProps = obj .REQUIRED( typeKey );
234
244
else
235
245
mc = metaclass(obj );
236
246
propertyDescription = {mc .PropertyList .Description };
237
247
isRequired = startsWith(propertyDescription , ' REQUIRED' );
238
248
requiredProps = {mc .PropertyList(isRequired ).Name};
239
- obj .REQUIRED( class( obj ) ) = requiredProps ;
249
+ obj .REQUIRED( typeKey ) = requiredProps ;
240
250
end
241
251
end
242
252
@@ -262,3 +272,18 @@ function checkCustomConstraint(obj) %#ok<MANU>
262
272
end
263
273
end
264
274
end
275
+
276
+ function version = getNamespaceVersionForType(typeClassName )
277
+ if strcmp(typeClassName , ' NwbFile' )
278
+ namespaceName = ' types.core' ;
279
+ else
280
+ classNameParts = strsplit(typeClassName , ' .' );
281
+ namespaceName = strjoin(classNameParts(1 : end - 1 ), ' .' );
282
+ end
283
+ assert(startsWith(namespaceName , ' types.' ), ...
284
+ ' Expected type to belong to namespace.' )
285
+
286
+ version = feval( ...
287
+ sprintf(' %s .%s ' , namespaceName , matnwb .common .constant .VERSIONFUNCTION ) ...
288
+ );
289
+ end
0 commit comments