platform/angel_serialize_generator/test/models/book.g.dart

203 lines
5 KiB
Dart
Raw Normal View History

2017-06-17 01:26:19 +00:00
// GENERATED CODE - DO NOT MODIFY BY HAND
part of angel_serialize.test.models.book;
// **************************************************************************
// Generator: JsonModelGenerator
// **************************************************************************
class Book extends _Book {
@override
String id;
@override
String author;
@override
String title;
@override
String description;
@override
int pageCount;
@override
DateTime createdAt;
@override
DateTime updatedAt;
Book(
{this.id,
this.author,
this.title,
this.description,
this.pageCount,
this.createdAt,
this.updatedAt});
factory Book.fromJson(Map data) {
return new Book(
id: data['id'],
author: data['author'],
title: data['title'],
description: data['description'],
pageCount: data['page_count'],
2017-06-20 22:13:04 +00:00
createdAt: data['created_at'] is DateTime
? data['created_at']
: (data['created_at'] is String
? DateTime.parse(data['created_at'])
2017-06-17 01:26:19 +00:00
: null),
2017-06-20 22:13:04 +00:00
updatedAt: data['updated_at'] is DateTime
? data['updated_at']
: (data['updated_at'] is String
? DateTime.parse(data['updated_at'])
2017-06-17 01:26:19 +00:00
: null));
}
Map<String, dynamic> toJson() => {
'id': id,
'author': author,
'title': title,
'description': description,
'page_count': pageCount,
2017-06-20 22:13:04 +00:00
'created_at': createdAt == null ? null : createdAt.toIso8601String(),
'updated_at': updatedAt == null ? null : updatedAt.toIso8601String()
2017-06-17 01:26:19 +00:00
};
static Book parse(Map map) => new Book.fromJson(map);
2017-07-10 15:15:09 +00:00
Book clone() {
return new Book.fromJson(toJson());
}
2017-06-17 01:26:19 +00:00
}
class Author extends _Author {
@override
String id;
@override
String name;
@override
int age;
@override
List<_Book> books;
@override
_Book newestBook;
@override
2017-06-20 22:13:04 +00:00
DateTime createdAt;
@override
DateTime updatedAt;
2017-06-17 01:26:19 +00:00
Author(
{this.id,
this.name,
this.age,
this.books,
this.newestBook,
2017-06-20 22:13:04 +00:00
this.createdAt,
this.updatedAt});
2017-06-17 01:26:19 +00:00
factory Author.fromJson(Map data) {
return new Author(
id: data['id'],
name: data['name'],
age: data['age'],
books: data['books'] is List
? data['books']
.map((x) =>
x == null ? null : (x is Book ? x : new Book.fromJson(x)))
.toList()
: null,
2017-09-15 00:20:36 +00:00
newestBook: data['newest_book'] is Book
? data['newest_book']
: new Book.fromJson(data['newest_book']),
2017-06-20 22:13:04 +00:00
createdAt: data['created_at'] is DateTime
? data['created_at']
: (data['created_at'] is String
? DateTime.parse(data['created_at'])
: null),
updatedAt: data['updated_at'] is DateTime
? data['updated_at']
: (data['updated_at'] is String
? DateTime.parse(data['updated_at'])
: null));
2017-06-17 01:26:19 +00:00
}
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'age': age,
'books': books,
2017-09-15 00:20:36 +00:00
'newest_book': newestBook.toJson(),
2017-06-20 22:13:04 +00:00
'created_at': createdAt == null ? null : createdAt.toIso8601String(),
'updated_at': updatedAt == null ? null : updatedAt.toIso8601String()
2017-06-17 01:26:19 +00:00
};
static Author parse(Map map) => new Author.fromJson(map);
2017-07-10 15:15:09 +00:00
Author clone() {
return new Author.fromJson(toJson());
}
2017-06-17 01:26:19 +00:00
}
class Library extends _Library {
@override
String id;
@override
2017-06-20 22:13:04 +00:00
Map<String, _Book> collection;
2017-06-17 01:26:19 +00:00
@override
2017-06-20 22:13:04 +00:00
DateTime createdAt;
2017-06-17 01:26:19 +00:00
@override
2017-06-20 22:13:04 +00:00
DateTime updatedAt;
2017-06-17 01:26:19 +00:00
2017-06-20 22:13:04 +00:00
Library({this.id, this.collection, this.createdAt, this.updatedAt});
2017-06-17 01:26:19 +00:00
factory Library.fromJson(Map data) {
return new Library(
id: data['id'],
collection: data['collection'] is Map
? data['collection'].keys.fold({}, (out, k) {
out[k] = data['collection'][k] == null
? null
: (data['collection'][k] is Book
? data['collection'][k]
: new Book.fromJson(data['collection'][k]));
return out;
})
2017-06-20 22:13:04 +00:00
: null,
createdAt: data['created_at'] is DateTime
? data['created_at']
: (data['created_at'] is String
? DateTime.parse(data['created_at'])
: null),
updatedAt: data['updated_at'] is DateTime
? data['updated_at']
: (data['updated_at'] is String
? DateTime.parse(data['updated_at'])
: null));
2017-06-17 01:26:19 +00:00
}
Map<String, dynamic> toJson() => {
'id': id,
2017-06-20 22:13:04 +00:00
'collection': collection,
'created_at': createdAt == null ? null : createdAt.toIso8601String(),
'updated_at': updatedAt == null ? null : updatedAt.toIso8601String()
2017-06-17 01:26:19 +00:00
};
static Library parse(Map map) => new Library.fromJson(map);
2017-07-10 15:15:09 +00:00
Library clone() {
return new Library.fromJson(toJson());
}
2017-06-17 01:26:19 +00:00
}