maybeMap<TResult extends Object?> method

TResult maybeMap<TResult extends Object?>({
  1. TResult perMille(
    1. UpgradedGiftAttributeRarityPerMille value
    )?,
  2. TResult uncommon(
    1. UpgradedGiftAttributeRarityUncommon value
    )?,
  3. TResult rare(
    1. UpgradedGiftAttributeRarityRare value
    )?,
  4. TResult epic(
    1. UpgradedGiftAttributeRarityEpic value
    )?,
  5. TResult legendary(
    1. UpgradedGiftAttributeRarityLegendary value
    )?,
  6. required TResult orElse(),
})

Implementation

TResult maybeMap<TResult extends Object?>({
  TResult Function(UpgradedGiftAttributeRarityPerMille value)? perMille,
  TResult Function(UpgradedGiftAttributeRarityUncommon value)? uncommon,
  TResult Function(UpgradedGiftAttributeRarityRare value)? rare,
  TResult Function(UpgradedGiftAttributeRarityEpic value)? epic,
  TResult Function(UpgradedGiftAttributeRarityLegendary value)? legendary,
  required TResult Function() orElse,
}) {
  switch (getConstructor()) {
    case UpgradedGiftAttributeRarityPerMille.constructor:
      if (perMille != null) {
        return perMille.call(this as UpgradedGiftAttributeRarityPerMille);
      }
      break;
    case UpgradedGiftAttributeRarityUncommon.constructor:
      if (uncommon != null) {
        return uncommon.call(this as UpgradedGiftAttributeRarityUncommon);
      }
      break;
    case UpgradedGiftAttributeRarityRare.constructor:
      if (rare != null) {
        return rare.call(this as UpgradedGiftAttributeRarityRare);
      }
      break;
    case UpgradedGiftAttributeRarityEpic.constructor:
      if (epic != null) {
        return epic.call(this as UpgradedGiftAttributeRarityEpic);
      }
      break;
    case UpgradedGiftAttributeRarityLegendary.constructor:
      if (legendary != null) {
        return legendary.call(this as UpgradedGiftAttributeRarityLegendary);
      }
      break;
  }
  return orElse.call();
}