platform/angel_serialize_generator/test/models/author.dart

53 lines
1.2 KiB
Dart
Raw Normal View History

2017-12-07 07:08:32 +00:00
library angel_serialize.test.models.author;
2018-06-23 04:52:46 +00:00
import 'package:angel_model/angel_model.dart';
2017-12-07 07:08:32 +00:00
import 'package:angel_serialize/angel_serialize.dart';
2018-05-13 18:02:47 +00:00
import 'package:collection/collection.dart';
import 'package:meta/meta.dart';
2017-12-07 07:08:32 +00:00
import 'book.dart';
part 'author.g.dart';
2018-03-29 19:58:36 +00:00
2018-12-09 22:55:52 +00:00
@Serializable(serializers: Serializers.all)
2017-12-07 07:08:32 +00:00
abstract class _Author extends Model {
2019-01-07 01:38:04 +00:00
@SerializableField(isNullable: false)
2018-05-13 16:50:59 +00:00
String get name;
2018-06-27 05:51:21 +00:00
String get customMethod => 'hey!';
2019-01-07 01:38:04 +00:00
@SerializableField(
isNullable: false, errorMessage: 'Custom message for missing `age`')
2018-05-13 16:50:59 +00:00
int get age;
2019-04-04 21:40:36 +00:00
@nullable
2018-05-13 16:50:59 +00:00
List<Book> get books;
2019-04-04 21:40:36 +00:00
@nullable
2018-05-13 16:50:59 +00:00
Book get newestBook;
2019-04-04 21:40:36 +00:00
@SerializableField(exclude: true, isNullable: true)
2018-05-13 16:50:59 +00:00
String get secret;
2019-04-04 21:40:36 +00:00
@SerializableField(exclude: true, canDeserialize: true, isNullable: true)
2018-05-13 16:50:59 +00:00
String get obscured;
2017-12-07 07:08:32 +00:00
}
2018-03-29 19:58:36 +00:00
@Serializable(serializers: Serializers.all)
2017-12-07 07:08:32 +00:00
abstract class _Library extends Model {
2018-05-13 16:50:59 +00:00
Map<String, Book> get collection;
2018-02-28 00:36:53 +00:00
}
2018-05-13 17:23:40 +00:00
2018-05-13 18:02:47 +00:00
@Serializable(serializers: Serializers.all)
2018-05-13 17:23:40 +00:00
abstract class _Bookmark extends Model {
2019-01-07 00:56:05 +00:00
@SerializableField(exclude: true)
2018-05-13 17:23:40 +00:00
final Book book;
2018-05-13 18:02:47 +00:00
List<int> get history;
2019-01-07 01:38:04 +00:00
@SerializableField(isNullable: false)
2018-05-13 17:23:40 +00:00
int get page;
2018-05-13 17:23:40 +00:00
String get comment;
2018-05-13 18:02:47 +00:00
2018-05-13 17:23:40 +00:00
_Bookmark(this.book);
}