platform/angel_serialize_generator/test/models/book.dart

70 lines
1.5 KiB
Dart
Raw Normal View History

2017-06-17 01:26:19 +00:00
library angel_serialize.test.models.book;
2018-06-23 04:52:46 +00:00
import 'package:angel_model/angel_model.dart';
2017-06-17 01:26:19 +00:00
import 'package:angel_serialize/angel_serialize.dart';
2018-05-13 18:02:47 +00:00
import 'package:collection/collection.dart';
2019-04-08 04:41:58 +00:00
import 'package:meta/meta.dart';
2017-06-17 01:26:19 +00:00
part 'book.g.dart';
2019-01-07 00:56:05 +00:00
@Serializable(
serializers: Serializers.all,
includeAnnotations: [
pragma('hello'),
SerializableField(alias: 'omg'),
],
)
2017-06-17 01:26:19 +00:00
abstract class _Book extends Model {
String author, title, description;
2019-04-08 15:00:04 +00:00
/// The number of pages the book has.
2017-06-17 01:26:19 +00:00
int pageCount;
2019-04-08 15:00:04 +00:00
2018-03-05 06:18:46 +00:00
List<double> notModels;
2018-03-09 12:43:17 +00:00
2019-04-04 21:40:36 +00:00
@SerializableField(alias: 'camelCase', isNullable: true)
2018-03-09 12:43:17 +00:00
String camelCaseString;
2018-07-11 15:49:46 +00:00
}
2019-04-08 04:41:58 +00:00
@Serializable(serializers: Serializers.all)
abstract class _Author extends Model {
@SerializableField(isNullable: false)
String get name;
String get customMethod => 'hey!';
@SerializableField(
isNullable: false, errorMessage: 'Custom message for missing `age`')
int get age;
List<_Book> get books;
2019-04-08 15:00:04 +00:00
/// The newest book.
2019-04-08 04:41:58 +00:00
_Book get newestBook;
@SerializableField(exclude: true, isNullable: true)
String get secret;
@SerializableField(exclude: true, canDeserialize: true, isNullable: true)
String get obscured;
}
@Serializable(serializers: Serializers.all)
abstract class _Library extends Model {
Map<String, _Book> get collection;
}
@Serializable(serializers: Serializers.all)
abstract class _Bookmark extends Model {
@SerializableField(exclude: true)
final _Book book;
List<int> get history;
@SerializableField(isNullable: false)
int get page;
String get comment;
_Bookmark(this.book);
}