allParents function

String allParents(
  1. dynamic parents,
  2. String text
)

Implementation

String allParents(parents, String text) {
  if (!(parents is IEntities)) {
    return parents.codePluralFirstLetterLower;
  }

  if (parents.length == 0) {
    return text;
  }
  var entryParents = parents.where((entity) => entity.concept.entry);

  if (entryParents == 0) {
    return text;
  }
  if (entryParents == 1) {
    return '$text.${(entryParents as Parents).first.codePluralFirstLetterLower}';
  }

  final parsedParent = entryParents.first as Parent;
  final newText = '$text.${parsedParent.code}';
  final restParents = entryParents.where((element) => element != parsedParent);

  return allParents(restParents, newText);
}