freezer/lib/api/cache.g.dart
2023-07-29 04:17:26 +02:00

201 lines
5.8 KiB
Dart

// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'cache.dart';
// **************************************************************************
// TypeAdapterGenerator
// **************************************************************************
class CacheAdapter extends TypeAdapter<Cache> {
@override
final int typeId = 22;
@override
Cache read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields = <int, dynamic>{
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return Cache(
libraryTracks: (fields[0] as List?)?.cast<String>(),
)
..loggedTrackId = fields[1] as String?
..history = (fields[2] as List).cast<Track>()
..sorts = (fields[3] as List).cast<Sorting?>()
..searchHistory = (fields[4] as List).cast<SearchHistoryItem>()
..threadsWarning = fields[5] as bool
..lastUpdateCheck = fields[6] as DateTime?
..favoritesPlaylistId = fields[7] as String?;
}
@override
void write(BinaryWriter writer, Cache obj) {
writer
..writeByte(8)
..writeByte(0)
..write(obj.libraryTracks)
..writeByte(1)
..write(obj.loggedTrackId)
..writeByte(2)
..write(obj.history)
..writeByte(3)
..write(obj.sorts)
..writeByte(4)
..write(obj.searchHistory)
..writeByte(5)
..write(obj.threadsWarning)
..writeByte(6)
..write(obj.lastUpdateCheck)
..writeByte(7)
..write(obj.favoritesPlaylistId);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is CacheAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
class SearchHistoryItemAdapter extends TypeAdapter<SearchHistoryItem> {
@override
final int typeId = 20;
@override
SearchHistoryItem read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields = <int, dynamic>{
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return SearchHistoryItem(
fields[1] as dynamic,
fields[0] as SearchHistoryItemType,
);
}
@override
void write(BinaryWriter writer, SearchHistoryItem obj) {
writer
..writeByte(2)
..writeByte(0)
..write(obj.type)
..writeByte(1)
..write(obj.data);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is SearchHistoryItemAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
class SearchHistoryItemTypeAdapter extends TypeAdapter<SearchHistoryItemType> {
@override
final int typeId = 21;
@override
SearchHistoryItemType read(BinaryReader reader) {
switch (reader.readByte()) {
case 0:
return SearchHistoryItemType.TRACK;
case 1:
return SearchHistoryItemType.ALBUM;
case 2:
return SearchHistoryItemType.ARTIST;
case 3:
return SearchHistoryItemType.PLAYLIST;
default:
return SearchHistoryItemType.TRACK;
}
}
@override
void write(BinaryWriter writer, SearchHistoryItemType obj) {
switch (obj) {
case SearchHistoryItemType.TRACK:
writer.writeByte(0);
break;
case SearchHistoryItemType.ALBUM:
writer.writeByte(1);
break;
case SearchHistoryItemType.ARTIST:
writer.writeByte(2);
break;
case SearchHistoryItemType.PLAYLIST:
writer.writeByte(3);
break;
}
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is SearchHistoryItemTypeAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Cache _$CacheFromJson(Map<String, dynamic> json) => Cache(
libraryTracks: (json['libraryTracks'] as List<dynamic>?)
?.map((e) => e as String)
.toList(),
)
..history = (json['history'] as List<dynamic>?)
?.map((e) => Track.fromJson(e as Map<String, dynamic>))
.toList() ??
[]
..sorts = (json['sorts'] as List<dynamic>?)
?.map((e) => e == null
? null
: Sorting.fromJson(e as Map<String, dynamic>))
.toList() ??
[]
..searchHistory = (json['searchHistory2'] as List<dynamic>?)
?.map(
(e) => SearchHistoryItem.fromJson(e as Map<String, dynamic>))
.toList() ??
[]
..threadsWarning = json['threadsWarning'] as bool? ?? false
..lastUpdateCheck = json['lastUpdateCheck'] == null
? null
: DateTime.parse(json['lastUpdateCheck'] as String)
..favoritesPlaylistId = json['favoritesPlaylistId'] as String?;
Map<String, dynamic> _$CacheToJson(Cache instance) => <String, dynamic>{
'libraryTracks': instance.libraryTracks,
'history': instance.history,
'sorts': instance.sorts,
'searchHistory2': instance.searchHistory,
'threadsWarning': instance.threadsWarning,
'lastUpdateCheck': instance.lastUpdateCheck?.toIso8601String(),
'favoritesPlaylistId': instance.favoritesPlaylistId,
};
SearchHistoryItem _$SearchHistoryItemFromJson(Map<String, dynamic> json) =>
SearchHistoryItem(
json['data'],
SearchHistoryItem._searchHistoryItemTypeFromJson(json['type'] as int),
);
Map<String, dynamic> _$SearchHistoryItemToJson(SearchHistoryItem instance) =>
<String, dynamic>{
'type': SearchHistoryItem._searchHistoryItemTypeToJson(instance.type),
'data': instance.data,
};