determineCategory method
Tries to determine the UICCategory of uic
. Returns null
for
7-digit long and invalid UIC numbers, as well as UIC number whose category
couldn't be determined.
Implementation
UICCategory? determineCategory(String uic) {
for (final category in UICCategory.values) {
final details = extractUICValues(uic, category);
final relevantDescriptions = category == UICCategory.freightWagon ? 3 : 2;
if (!details.take(relevantDescriptions).map((detail) => detail.description).contains(null)) {
return category;
}
}
return null;
}