platform/angel_serialize_generator/test/models/author.serializer.g.dart

110 lines
3.2 KiB
Dart
Raw Normal View History

// GENERATED CODE - DO NOT MODIFY BY HAND
part of angel_serialize.test.models.author;
// **************************************************************************
// Generator: SerializerGenerator
// **************************************************************************
2018-02-28 01:10:57 +00:00
abstract class AuthorSerializer {
2018-03-09 12:45:03 +00:00
static Author fromMap(Map map) {
2018-02-28 02:10:43 +00:00
return new Author(
id: map['id'],
name: map['name'],
age: map['age'],
books: map['books'] is Iterable
? map['books'].map(BookSerializer.fromMap).toList()
: null,
newestBook: map['newest_book'] != null
? BookSerializer.fromMap(map['newest_book'])
: null,
obscured: map['obscured'],
2018-02-28 02:10:43 +00:00
createdAt: map['created_at'] != null
? (map['created_at'] is DateTime
? map['created_at']
: DateTime.parse(map['created_at']))
2018-02-28 02:10:43 +00:00
: null,
updatedAt: map['updated_at'] != null
? (map['updated_at'] is DateTime
? map['updated_at']
: DateTime.parse(map['updated_at']))
2018-02-28 02:10:43 +00:00
: null);
}
2018-02-28 01:41:19 +00:00
static Map<String, dynamic> toMap(Author model) {
2018-02-28 01:10:57 +00:00
return {
2018-02-28 01:41:19 +00:00
'id': model.id,
'name': model.name,
'age': model.age,
2018-02-28 02:10:43 +00:00
'books': model.books?.map(BookSerializer.toMap)?.toList(),
2018-02-28 01:41:19 +00:00
'newest_book': BookSerializer.toMap(model.newestBook),
2018-02-28 02:10:43 +00:00
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
2018-02-28 01:10:57 +00:00
};
}
}
2018-03-09 12:39:21 +00:00
abstract class AuthorFields {
static const String id = 'id';
static const String name = 'name';
static const String age = 'age';
static const String books = 'books';
static const String newestBook = 'newest_book';
static const String secret = 'secret';
static const String obscured = 'obscured';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}
2018-02-28 01:10:57 +00:00
abstract class LibrarySerializer {
2018-03-09 12:45:03 +00:00
static Library fromMap(Map map) {
2018-02-28 02:10:43 +00:00
return new Library(
id: map['id'],
collection: map['collection'] is Map
? map['collection'].keys.fold({}, (out, key) {
return out
..[key] = BookSerializer.fromMap(map['collection'][key]);
})
: null,
createdAt: map['created_at'] != null
? (map['created_at'] is DateTime
? map['created_at']
: DateTime.parse(map['created_at']))
2018-02-28 02:10:43 +00:00
: null,
updatedAt: map['updated_at'] != null
? (map['updated_at'] is DateTime
? map['updated_at']
: DateTime.parse(map['updated_at']))
2018-02-28 02:10:43 +00:00
: null);
}
2018-02-28 01:41:19 +00:00
static Map<String, dynamic> toMap(Library model) {
2018-02-28 01:10:57 +00:00
return {
2018-02-28 01:41:19 +00:00
'id': model.id,
2018-02-28 02:10:43 +00:00
'collection': model.collection.keys?.fold({}, (map, key) {
2018-02-28 01:43:43 +00:00
return map..[key] = BookSerializer.toMap(model.collection[key]);
}),
2018-02-28 02:10:43 +00:00
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
2018-02-28 01:10:57 +00:00
};
}
}
2018-03-09 12:39:21 +00:00
abstract class LibraryFields {
static const String id = 'id';
static const String collection = 'collection';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}