getType function
Get type from types
*/
Implementation
Type getType(Map<String, Type> types, String name) {
var type = types[name];
if (type != null && type.aliasOfName.isNotEmpty) {
return getType(types, type.aliasOfName);
}
if (type != null) {
return type;
}
if (name.endsWith('[]')) {
return createType(
name: name,
arrayOf: getType(types, name.substring(0, name.length - 2)),
serialize: serializeArray,
deserialize: deserializeArray,
);
}
if (name.endsWith('?')) {
return createType(
name: name,
optionalOf: getType(types, name.substring(0, name.length - 1)),
serialize: serializeOptional,
deserialize: deserializeOptional,
);
}
if (name.endsWith("\$")) {
return createType(
name: name,
extensionOf: getType(types, name.substring(0, name.length - 1)),
serialize: serializeExtension,
deserialize: deserializeExtension,
);
}
throw 'Unknown type: ' + name;
}