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

95 lines
2.3 KiB
Dart
Raw Normal View History

2018-12-31 01:18:44 +00:00
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'goat.dart';
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
class Goat implements _Goat {
2019-04-04 21:40:36 +00:00
const Goat({this.integer = 34, List<int> this.list = const [34, 35]});
2018-12-31 01:18:44 +00:00
@override
final int integer;
@override
final List<int> list;
Goat copyWith({int integer, List<int> list}) {
return new Goat(integer: integer ?? this.integer, list: list ?? this.list);
}
bool operator ==(other) {
return other is _Goat &&
other.integer == integer &&
const ListEquality<int>(const DefaultEquality<int>())
.equals(other.list, list);
}
@override
int get hashCode {
return hashObjects([integer, list]);
}
2019-04-08 15:00:04 +00:00
@override
String toString() {
return "Goat(integer=$integer, list=$list)";
}
2018-12-31 01:18:44 +00:00
Map<String, dynamic> toJson() {
return GoatSerializer.toMap(this);
}
}
// **************************************************************************
// SerializerGenerator
// **************************************************************************
2019-04-08 15:00:04 +00:00
const GoatSerializer goatSerializer = const GoatSerializer();
class GoatEncoder extends Converter<Goat, Map> {
const GoatEncoder();
@override
Map convert(Goat model) => GoatSerializer.toMap(model);
}
class GoatDecoder extends Converter<Map, Goat> {
const GoatDecoder();
@override
Goat convert(Map map) => GoatSerializer.fromMap(map);
}
class GoatSerializer extends Codec<Goat, Map> {
const GoatSerializer();
@override
get encoder => const GoatEncoder();
@override
get decoder => const GoatDecoder();
2018-12-31 01:18:44 +00:00
static Goat fromMap(Map map) {
return new Goat(
integer: map['integer'] as int ?? 34,
list: map['list'] is Iterable
? (map['list'] as Iterable).cast<int>().toList()
: const [34, 35]);
}
static Map<String, dynamic> toMap(_Goat model) {
if (model == null) {
return null;
}
return {'integer': model.integer, 'list': model.list};
}
}
abstract class GoatFields {
2019-04-04 21:40:36 +00:00
static const List<String> allFields = <String>[integer, list];
2018-12-31 01:18:44 +00:00
static const String integer = 'integer';
static const String list = 'list';
}