maybeMap<TResult extends Object?> method

TResult maybeMap<TResult extends Object?>({
  1. TResult $boolean(
    1. OptionValueBoolean value
    )?,
  2. TResult empty(
    1. OptionValueEmpty value
    )?,
  3. TResult integer(
    1. OptionValueInteger value
    )?,
  4. TResult $string(
    1. OptionValueString value
    )?,
  5. required TResult orElse(),
})

Implementation

TResult maybeMap<TResult extends Object?>({
  TResult Function(OptionValueBoolean value)? $boolean,
  TResult Function(OptionValueEmpty value)? empty,
  TResult Function(OptionValueInteger value)? integer,
  TResult Function(OptionValueString value)? $string,
  required TResult Function() orElse,
}) {
  switch (getConstructor()) {
    case OptionValueBoolean.constructor:
      if ($boolean != null) {
        return $boolean.call(this as OptionValueBoolean);
      }
      break;
    case OptionValueEmpty.constructor:
      if (empty != null) {
        return empty.call(this as OptionValueEmpty);
      }
      break;
    case OptionValueInteger.constructor:
      if (integer != null) {
        return integer.call(this as OptionValueInteger);
      }
      break;
    case OptionValueString.constructor:
      if ($string != null) {
        return $string.call(this as OptionValueString);
      }
      break;
  }
  return orElse.call();
}