isAllowedEntityType method

bool? isAllowedEntityType(
  1. Type type
)

Implementation

bool? isAllowedEntityType(Type type) {
  if (isInnocuous) return null;

  if (entityType == type) {
    switch (ruleType) {
      case EntityAccessRuleType.allow:
        {
          // If allows a field also allows a type (not checking `entityFields`):
          return true;
        }
      case EntityAccessRuleType.block:
        {
          final entityFields = this.entityFields;
          var fieldRule = entityFields != null && entityFields.isNotEmpty;

          // If blocks a field it's not fully blocking a type (allowed).
          // If there's NO field rule, the type is being blocked:
          return fieldRule;
        }
      case EntityAccessRuleType.mask:
        {
          // If masks a field also allows a type.
          return true;
        }
      default:
        {
          break;
        }
    }
  }

  return _lastDefined(rules, (r) => r.isAllowedEntityType(type));
}