resolveEntityResolutionRules method

EntityResolutionRulesResolved resolveEntityResolutionRules(
  1. EntityResolutionRules? resolutionRules
)

Resolves the resolutionRules to apply. Merges with the current EntityResolutionRules context if needed.

See getContextEntityResolutionRules and EntityResolutionRules.merge.

Implementation

EntityResolutionRulesResolved resolveEntityResolutionRules(
    EntityResolutionRules? resolutionRules) {
  var context = getContextEntityResolutionRules();

  if (context == null || context.isInnocuous) {
    if (resolutionRules is EntityResolutionRulesResolved) {
      return resolutionRules;
    }

    return _resolveEntityResolutionRulesNoContext(resolutionRules);
  }

  if (context is EntityResolutionRulesResolved) {
    if (resolutionRules == null || resolutionRules.isInnocuous) {
      return context;
    } else {
      context = context.resolved;
    }
  }

  if (resolutionRules is EntityResolutionRulesResolved) {
    if (identical(resolutionRules.contextRules, context)) {
      return resolutionRules;
    } else {
      resolutionRules = resolutionRules.resolved;
    }
  }

  return _resolveEntityResolutionRulesWithContext(context, resolutionRules);
}