system_config_key.dart 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // AUTO-GENERATED FILE, DO NOT MODIFY!
  3. //
  4. // @dart=2.12
  5. // ignore_for_file: unused_element, unused_import
  6. // ignore_for_file: always_put_required_named_parameters_first
  7. // ignore_for_file: constant_identifier_names
  8. // ignore_for_file: lines_longer_than_80_chars
  9. part of openapi.api;
  10. class SystemConfigKey {
  11. /// Instantiate a new enum with the provided [value].
  12. const SystemConfigKey._(this.value);
  13. /// The underlying value of this enum member.
  14. final String value;
  15. @override
  16. String toString() => value;
  17. String toJson() => value;
  18. static const crf = SystemConfigKey._(r'ffmpeg_crf');
  19. static const preset = SystemConfigKey._(r'ffmpeg_preset');
  20. static const targetVideoCodec = SystemConfigKey._(r'ffmpeg_target_video_codec');
  21. static const targetAudioCodec = SystemConfigKey._(r'ffmpeg_target_audio_codec');
  22. static const targetScaling = SystemConfigKey._(r'ffmpeg_target_scaling');
  23. /// List of all possible values in this [enum][SystemConfigKey].
  24. static const values = <SystemConfigKey>[
  25. crf,
  26. preset,
  27. targetVideoCodec,
  28. targetAudioCodec,
  29. targetScaling,
  30. ];
  31. static SystemConfigKey? fromJson(dynamic value) => SystemConfigKeyTypeTransformer().decode(value);
  32. static List<SystemConfigKey>? listFromJson(dynamic json, {bool growable = false,}) {
  33. final result = <SystemConfigKey>[];
  34. if (json is List && json.isNotEmpty) {
  35. for (final row in json) {
  36. final value = SystemConfigKey.fromJson(row);
  37. if (value != null) {
  38. result.add(value);
  39. }
  40. }
  41. }
  42. return result.toList(growable: growable);
  43. }
  44. }
  45. /// Transformation class that can [encode] an instance of [SystemConfigKey] to String,
  46. /// and [decode] dynamic data back to [SystemConfigKey].
  47. class SystemConfigKeyTypeTransformer {
  48. factory SystemConfigKeyTypeTransformer() => _instance ??= const SystemConfigKeyTypeTransformer._();
  49. const SystemConfigKeyTypeTransformer._();
  50. String encode(SystemConfigKey data) => data.value;
  51. /// Decodes a [dynamic value][data] to a SystemConfigKey.
  52. ///
  53. /// If [allowNull] is true and the [dynamic value][data] cannot be decoded successfully,
  54. /// then null is returned. However, if [allowNull] is false and the [dynamic value][data]
  55. /// cannot be decoded successfully, then an [UnimplementedError] is thrown.
  56. ///
  57. /// The [allowNull] is very handy when an API changes and a new enum value is added or removed,
  58. /// and users are still using an old app with the old code.
  59. SystemConfigKey? decode(dynamic data, {bool allowNull = true}) {
  60. if (data != null) {
  61. switch (data.toString()) {
  62. case r'ffmpeg_crf': return SystemConfigKey.crf;
  63. case r'ffmpeg_preset': return SystemConfigKey.preset;
  64. case r'ffmpeg_target_video_codec': return SystemConfigKey.targetVideoCodec;
  65. case r'ffmpeg_target_audio_codec': return SystemConfigKey.targetAudioCodec;
  66. case r'ffmpeg_target_scaling': return SystemConfigKey.targetScaling;
  67. default:
  68. if (!allowNull) {
  69. throw ArgumentError('Unknown enum value to decode: $data');
  70. }
  71. }
  72. }
  73. return null;
  74. }
  75. /// Singleton [SystemConfigKeyTypeTransformer] instance.
  76. static SystemConfigKeyTypeTransformer? _instance;
  77. }