mirror of
https://bitbucket.org/myhomie/mycorerepository.git
synced 2025-12-06 17:51:20 +00:00
80 lines
2.3 KiB
Dart
80 lines
2.3 KiB
Dart
//
|
|
// AUTO-GENERATED FILE, DO NOT MODIFY!
|
|
//
|
|
// @dart=2.0
|
|
|
|
// ignore_for_file: unused_element, unused_import
|
|
// ignore_for_file: always_put_required_named_parameters_first
|
|
// ignore_for_file: lines_longer_than_80_chars
|
|
|
|
part of openapi.api;
|
|
|
|
|
|
class ViewBy {
|
|
/// Instantiate a new enum with the provided [value].
|
|
const ViewBy._(this.value);
|
|
|
|
/// The underlying value of this enum member.
|
|
final String value;
|
|
|
|
@override
|
|
String toString() => value;
|
|
|
|
String toJson() => value;
|
|
|
|
static const year = ViewBy._(r'Year');
|
|
static const month = ViewBy._(r'Month');
|
|
static const day = ViewBy._(r'Day');
|
|
|
|
/// List of all possible values in this [enum][ViewBy].
|
|
static const values = <ViewBy>[
|
|
year,
|
|
month,
|
|
day,
|
|
];
|
|
|
|
static ViewBy fromJson(dynamic value) =>
|
|
ViewByTypeTransformer().decode(value);
|
|
|
|
static List<ViewBy> listFromJson(List<dynamic> json, {bool emptyIsNull, bool growable,}) =>
|
|
json == null || json.isEmpty
|
|
? true == emptyIsNull ? null : <ViewBy>[]
|
|
: json
|
|
.map((value) => ViewBy.fromJson(value))
|
|
.toList(growable: true == growable);
|
|
}
|
|
|
|
/// Transformation class that can [encode] an instance of [ViewBy] to String,
|
|
/// and [decode] dynamic data back to [ViewBy].
|
|
class ViewByTypeTransformer {
|
|
const ViewByTypeTransformer._();
|
|
|
|
factory ViewByTypeTransformer() => _instance ??= ViewByTypeTransformer._();
|
|
|
|
String encode(ViewBy data) => data.value;
|
|
|
|
/// Decodes a [dynamic value][data] to a ViewBy.
|
|
///
|
|
/// 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.
|
|
ViewBy decode(dynamic data, {bool allowNull}) {
|
|
switch (data) {
|
|
case r'Year': return ViewBy.year;
|
|
case r'Month': return ViewBy.month;
|
|
case r'Day': return ViewBy.day;
|
|
default:
|
|
if (allowNull == false) {
|
|
throw ArgumentError('Unknown enum value to decode: $data');
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/// Singleton [ViewByTypeTransformer] instance.
|
|
static ViewByTypeTransformer _instance;
|
|
}
|