oc-front/lib/models/search.dart

34 lines
1.3 KiB
Dart
Raw Normal View History

import 'package:oc_front/models/abstract.dart';
2025-02-04 17:02:49 +01:00
import 'package:oc_front/models/resources/compute.dart';
import 'package:oc_front/models/resources/data.dart';
import 'package:oc_front/models/resources/processing.dart';
import 'package:oc_front/models/resources/storage.dart';
class Search extends SerializerDeserializer<Search> {
Search({
2025-02-04 17:02:49 +01:00
this.computing = const [],
this.compute = const [],
this.data = const [],
this.storage = const [],
});
2024-08-08 08:42:32 +02:00
List<ProcessingItem> computing;
2024-11-08 13:59:22 +01:00
List<ComputeItem> compute;
List<DataItem> data;
List<StorageItem> storage;
@override deserialize(dynamic json) {
json = json as Map<String, dynamic>;
return Search(
2024-08-08 08:42:32 +02:00
computing: json.containsKey("processing") ? fromListJson(json["processing"], ProcessingItem()) : [],
2024-11-08 13:59:22 +01:00
compute: json.containsKey("compute") ? fromListJson(json["compute"], ComputeItem()) : [],
data: json.containsKey("data") ? fromListJson(json["data"], DataItem()) : [],
storage: json.containsKey("storage") ? fromListJson(json["storage"], StorageItem()) : [],
);
}
2024-08-08 08:42:32 +02:00
@override Map<String, dynamic> serialize() => {
"processing": toListJson<ProcessingItem>(computing),
2024-11-08 13:59:22 +01:00
"compute": toListJson<ComputeItem>(compute),
2024-08-08 08:42:32 +02:00
"data": toListJson<DataItem>(data),
"storage": toListJson<StorageItem>(storage),
};
}