onTypeSelect<T> function
Pattern matches on AbiType and executes appropriate callback.
Parameters
type- AbiType to pattern matchcallbacks- TypeMatchCallbacks with handlers for each type category
Returns
T - Result of executed callback
Throws
UnsupportedError- If no callback provided for matched type
Implementation
T onTypeSelect<T>(AbiType type, TypeMatchCallbacks<T> callbacks) {
if (type is U8Type ||
type is U16Type ||
type is U32Type ||
type is U64Type ||
type is I8Type ||
type is I16Type ||
type is I32Type ||
type is I64Type ||
type is BigUIntType ||
type is BigIntType ||
type is AddressType ||
type is BooleanType ||
type is StringType ||
type is BytesType) {
return callbacks.onPrimitive();
}
if (type is OptionType) {
return callbacks.onOption();
}
if (type is ListType) {
return callbacks.onList();
}
if (type is ArrayType) {
return callbacks.onArray();
}
if (type is StructType) {
return callbacks.onStruct();
}
if (type is TupleType) {
return callbacks.onTuple();
}
if (type is EnumType) {
return callbacks.onEnum();
}
if (type is ExplicitEnumType) {
return callbacks.onExplicitEnum();
}
if (type is VariadicType) {
return callbacks.onVariadic();
}
if (type is NothingType) {
return callbacks.onNothing();
}
if (type is H256Type) {
return callbacks.onH256();
}
if (type is ManagedByteArrayType) {
return callbacks.onManagedByteArray();
}
if (type is TokenIdentifierType) {
return callbacks.onTokenIdentifier();
}
if (type is EgldOrEsdtTokenIdentifierType) {
return callbacks.onEgldOrEsdtTokenIdentifier();
}
if (type is OptionalType) {
return callbacks.onOptional();
}
if (type is CompositeType) {
return callbacks.onComposite();
}
if (type is CodeMetadataType) {
return callbacks.onCodeMetadata();
}
if (type is ManagedDecimalSignedType) {
return callbacks.onManagedDecimalSigned();
}
if (type is ManagedDecimalType) {
return callbacks.onManagedDecimal();
}
return callbacks.onOther();
}