job_command.dart 2.8 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 JobCommand {
  11. /// Instantiate a new enum with the provided [value].
  12. const JobCommand._(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 start = JobCommand._(r'start');
  19. static const pause = JobCommand._(r'pause');
  20. static const resume = JobCommand._(r'resume');
  21. static const empty = JobCommand._(r'empty');
  22. static const clearFailed = JobCommand._(r'clear-failed');
  23. /// List of all possible values in this [enum][JobCommand].
  24. static const values = <JobCommand>[
  25. start,
  26. pause,
  27. resume,
  28. empty,
  29. clearFailed,
  30. ];
  31. static JobCommand? fromJson(dynamic value) => JobCommandTypeTransformer().decode(value);
  32. static List<JobCommand>? listFromJson(dynamic json, {bool growable = false,}) {
  33. final result = <JobCommand>[];
  34. if (json is List && json.isNotEmpty) {
  35. for (final row in json) {
  36. final value = JobCommand.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 [JobCommand] to String,
  46. /// and [decode] dynamic data back to [JobCommand].
  47. class JobCommandTypeTransformer {
  48. factory JobCommandTypeTransformer() => _instance ??= const JobCommandTypeTransformer._();
  49. const JobCommandTypeTransformer._();
  50. String encode(JobCommand data) => data.value;
  51. /// Decodes a [dynamic value][data] to a JobCommand.
  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. JobCommand? decode(dynamic data, {bool allowNull = true}) {
  60. if (data != null) {
  61. switch (data) {
  62. case r'start': return JobCommand.start;
  63. case r'pause': return JobCommand.pause;
  64. case r'resume': return JobCommand.resume;
  65. case r'empty': return JobCommand.empty;
  66. case r'clear-failed': return JobCommand.clearFailed;
  67. default:
  68. if (!allowNull) {
  69. throw ArgumentError('Unknown enum value to decode: $data');
  70. }
  71. }
  72. }
  73. return null;
  74. }
  75. /// Singleton [JobCommandTypeTransformer] instance.
  76. static JobCommandTypeTransformer? _instance;
  77. }