match<T> method

T match<T>({
  1. required T empty(),
  2. required T boolean(
    1. bool value
    ),
  3. required T number(
    1. double value
    ),
  4. required T integer(
    1. int value
    ),
  5. required T string(
    1. String value
    ),
  6. required T data(
    1. ByteData value
    ),
  7. required T array(
    1. List<AttributeValue> value
    ),
  8. required T object(
    1. Map<String, AttributeValue> value
    ),
})

Implementation

T match<T>({
  required T Function() empty,
  required T Function(bool value) boolean,
  required T Function(double value) number,
  required T Function(int value) integer,
  required T Function(String value) string,
  required T Function(ByteData value) data,
  required T Function(List<AttributeValue> value) array,
  required T Function(core.Map<String, AttributeValue> value) object,
}) {
  return switch (this._index) {
    0 => empty(),
    1 => boolean(this._value as bool),
    2 => number(this._value as double),
    3 => integer(this._value as int),
    4 => string(this._value as String),
    5 => data(this._value as ByteData),
    6 => array(this._value as List<AttributeValue>),
    7 => object(this._value as core.Map<String, AttributeValue>),
    _ => throw NativeException("Unrecognized case index ${this._index}")
  };
}