2024-07-04 21:04:24 +02:00

99 lines
2.9 KiB
Dart

//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.12
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: constant_identifier_names
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
/// 0 = Google 1 = MapBox
class MapProvider {
/// Instantiate a new enum with the provided [value].
const MapProvider._(this.value);
/// The underlying value of this enum member.
final int value;
@override
String toString() => value.toString();
int toJson() => value;
static const Google = MapProvider._(0);
static const MapBox = MapProvider._(1);
/// List of all possible values in this [enum][MapProvider].
static const values = <MapProvider>[
Google,
MapBox,
];
static MapProvider? fromJson(dynamic value) => MapProviderTypeTransformer().decode(value);
static List<MapProvider> listFromJson(dynamic json, {bool growable = false,}) {
final result = <MapProvider>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = MapProvider.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
}
/// Transformation class that can [encode] an instance of [MapProvider] to int,
/// and [decode] dynamic data back to [MapProvider].
class MapProviderTypeTransformer {
factory MapProviderTypeTransformer() => _instance ??= const MapProviderTypeTransformer._();
const MapProviderTypeTransformer._();
int encode(MapProvider data) => data.value;
/// Decodes a [dynamic value][data] to a MapProvider.
///
/// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully,
/// then null is returned. However, if [allowNull] is false and the [dynamic value][data]
/// cannot be decoded successfully, then an [UnimplementedError] is thrown.
///
/// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
/// and users are still using an old app with the old code.
MapProvider? decode(dynamic data, {bool allowNull = true}) {
if (data != null) {
if(data.runtimeType == String) {
switch (data.toString().toLowerCase()) {
case r'google': return MapProvider.Google;
case r'mapbox': return MapProvider.MapBox;
default:
if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data');
}
}
} else {
if(data.runtimeType == int) {
switch (data) {
case 0: return MapProvider.Google;
case 1: return MapProvider.MapBox;
default:
if (!allowNull) {
throw ArgumentError('Unknown enum value to decode: $data');
}
}
}
}
}
return null;
}
/// Singleton [MapProviderTypeTransformer] instance.
static MapProviderTypeTransformer? _instance;
}