identification method

  1. @override
Future<AhpIdentification> identification(
  1. List<AhpItem> criteria,
  2. List<AhpItem> alternative
)
override

IDENTIFICATION DETAIL

Implementation

@override
Future<AhpIdentification> identification(
    List<AhpItem> criteria, List<AhpItem> alternative) async {
  startPerformanceProfiling('identification');

  try {
    _useIsolate = false;

    if (criteria.isEmpty) {
      throw Exception("Criteria can't be empty!");
    }
    if (alternative.isEmpty) {
      throw Exception("Alternative can't be empty!");
    }

    if (criteria.length > 100 || alternative.length > 100) {
      throw Exception(
        "Too much data, please limit the number of criteria/alternatives (max 100 criteria and 100 alternative).",
      );
    }

    final updatedCriteria = List<AhpItem>.generate(criteria.length, (i) {
      final e = criteria[i];
      return (e.id == null || e.id!.isEmpty)
          ? e.copyWith(id: _helper.getCustomUniqueId())
          : e;
    });

    final updateAlternative = List<AhpItem>.generate(alternative.length, (
      i,
    ) {
      final e = alternative[i];
      return (e.id == null || e.id!.isEmpty)
          ? e.copyWith(id: _helper.getCustomUniqueId())
          : e;
    });

    return AhpIdentification(
      criteria: updatedCriteria,
      alternative: updateAlternative,
    );
  } finally {
    endPerformanceProfiling('identification');
  }
}