maybeMap<TResult extends Object?> method

TResult maybeMap<TResult extends Object?>({
  1. TResult allowAll(
    1. UserPrivacySettingRuleAllowAll value
    )?,
  2. TResult allowContacts(
    1. UserPrivacySettingRuleAllowContacts value
    )?,
  3. TResult allowBots(
    1. UserPrivacySettingRuleAllowBots value
    )?,
  4. TResult allowPremiumUsers(
    1. UserPrivacySettingRuleAllowPremiumUsers value
    )?,
  5. TResult allowUsers(
    1. UserPrivacySettingRuleAllowUsers value
    )?,
  6. TResult allowChatMembers(
    1. UserPrivacySettingRuleAllowChatMembers value
    )?,
  7. TResult restrictAll(
    1. UserPrivacySettingRuleRestrictAll value
    )?,
  8. TResult restrictContacts(
    1. UserPrivacySettingRuleRestrictContacts value
    )?,
  9. TResult restrictBots(
    1. UserPrivacySettingRuleRestrictBots value
    )?,
  10. TResult restrictUsers(
    1. UserPrivacySettingRuleRestrictUsers value
    )?,
  11. TResult restrictChatMembers(
    1. UserPrivacySettingRuleRestrictChatMembers value
    )?,
  12. required TResult orElse(),
})

Implementation

TResult maybeMap<TResult extends Object?>({
  TResult Function(UserPrivacySettingRuleAllowAll value)? allowAll,
  TResult Function(UserPrivacySettingRuleAllowContacts value)? allowContacts,
  TResult Function(UserPrivacySettingRuleAllowBots value)? allowBots,
  TResult Function(UserPrivacySettingRuleAllowPremiumUsers value)?
      allowPremiumUsers,
  TResult Function(UserPrivacySettingRuleAllowUsers value)? allowUsers,
  TResult Function(UserPrivacySettingRuleAllowChatMembers value)?
      allowChatMembers,
  TResult Function(UserPrivacySettingRuleRestrictAll value)? restrictAll,
  TResult Function(UserPrivacySettingRuleRestrictContacts value)?
      restrictContacts,
  TResult Function(UserPrivacySettingRuleRestrictBots value)? restrictBots,
  TResult Function(UserPrivacySettingRuleRestrictUsers value)? restrictUsers,
  TResult Function(UserPrivacySettingRuleRestrictChatMembers value)?
      restrictChatMembers,
  required TResult Function() orElse,
}) {
  switch (getConstructor()) {
    case UserPrivacySettingRuleAllowAll.constructor:
      if (allowAll != null) {
        return allowAll.call(this as UserPrivacySettingRuleAllowAll);
      }
      break;
    case UserPrivacySettingRuleAllowContacts.constructor:
      if (allowContacts != null) {
        return allowContacts
            .call(this as UserPrivacySettingRuleAllowContacts);
      }
      break;
    case UserPrivacySettingRuleAllowBots.constructor:
      if (allowBots != null) {
        return allowBots.call(this as UserPrivacySettingRuleAllowBots);
      }
      break;
    case UserPrivacySettingRuleAllowPremiumUsers.constructor:
      if (allowPremiumUsers != null) {
        return allowPremiumUsers
            .call(this as UserPrivacySettingRuleAllowPremiumUsers);
      }
      break;
    case UserPrivacySettingRuleAllowUsers.constructor:
      if (allowUsers != null) {
        return allowUsers.call(this as UserPrivacySettingRuleAllowUsers);
      }
      break;
    case UserPrivacySettingRuleAllowChatMembers.constructor:
      if (allowChatMembers != null) {
        return allowChatMembers
            .call(this as UserPrivacySettingRuleAllowChatMembers);
      }
      break;
    case UserPrivacySettingRuleRestrictAll.constructor:
      if (restrictAll != null) {
        return restrictAll.call(this as UserPrivacySettingRuleRestrictAll);
      }
      break;
    case UserPrivacySettingRuleRestrictContacts.constructor:
      if (restrictContacts != null) {
        return restrictContacts
            .call(this as UserPrivacySettingRuleRestrictContacts);
      }
      break;
    case UserPrivacySettingRuleRestrictBots.constructor:
      if (restrictBots != null) {
        return restrictBots.call(this as UserPrivacySettingRuleRestrictBots);
      }
      break;
    case UserPrivacySettingRuleRestrictUsers.constructor:
      if (restrictUsers != null) {
        return restrictUsers
            .call(this as UserPrivacySettingRuleRestrictUsers);
      }
      break;
    case UserPrivacySettingRuleRestrictChatMembers.constructor:
      if (restrictChatMembers != null) {
        return restrictChatMembers
            .call(this as UserPrivacySettingRuleRestrictChatMembers);
      }
      break;
  }
  return orElse.call();
}