when<TResult extends Object?> method
- @optionalTypeArgs
- required TResult account(
- SplTokenAccountDataInfo info,
- String type,
- String? accountType
- required TResult mint(
- MintAccountDataInfo info,
- String type,
- String? accountType
- required TResult unknown(
- String type
A switch-like method, using callbacks.
As opposed to map, this offers destructuring.
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case Subclass2(:final field2):
return ...;
}
Implementation
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function( SplTokenAccountDataInfo info, String type, String? accountType) account,required TResult Function( MintAccountDataInfo info, String type, String? accountType) mint,required TResult Function( String type) unknown,}) {final _that = this;
switch (_that) {
case TokenAccountData():
return account(_that.info,_that.type,_that.accountType);case MintAccountData():
return mint(_that.info,_that.type,_that.accountType);case UnknownAccountData():
return unknown(_that.type);}
}