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

125 lines
3.5 KiB
Dart
Raw Normal View History

2018-06-27 05:36:57 +00:00
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'with_enum.dart';
// **************************************************************************
// JsonModelGenerator
2018-06-27 05:36:57 +00:00
// **************************************************************************
@generatedSerializable
2018-06-27 05:36:57 +00:00
class WithEnum implements _WithEnum {
2019-04-04 21:40:36 +00:00
const WithEnum(
{this.type = WithEnumType.b, List<int> this.finalList, this.imageBytes});
2018-06-27 05:36:57 +00:00
@override
final WithEnumType type;
2018-06-27 05:45:46 +00:00
@override
final List<int> finalList;
2018-12-08 20:53:49 +00:00
@override
final Uint8List imageBytes;
WithEnum copyWith(
{WithEnumType type, List<int> finalList, Uint8List imageBytes}) {
2018-06-27 05:45:46 +00:00
return new WithEnum(
2018-12-08 20:53:49 +00:00
type: type ?? this.type,
finalList: finalList ?? this.finalList,
imageBytes: imageBytes ?? this.imageBytes);
2018-06-27 05:36:57 +00:00
}
bool operator ==(other) {
2018-06-27 05:45:46 +00:00
return other is _WithEnum &&
other.type == type &&
const ListEquality<int>(const DefaultEquality<int>())
2018-12-08 20:53:49 +00:00
.equals(other.finalList, finalList) &&
const ListEquality().equals(other.imageBytes, imageBytes);
2018-06-27 05:36:57 +00:00
}
2018-11-03 07:36:59 +00:00
@override
int get hashCode {
2018-12-08 20:53:49 +00:00
return hashObjects([type, finalList, imageBytes]);
2018-11-03 07:36:59 +00:00
}
2019-04-08 15:00:04 +00:00
@override
String toString() {
return "WithEnum(type=$type, finalList=$finalList, imageBytes=$imageBytes)";
}
2018-06-27 05:36:57 +00:00
Map<String, dynamic> toJson() {
return WithEnumSerializer.toMap(this);
}
}
2018-12-08 20:53:49 +00:00
// **************************************************************************
// SerializerGenerator
// **************************************************************************
2019-04-08 15:00:04 +00:00
const WithEnumSerializer withEnumSerializer = const WithEnumSerializer();
class WithEnumEncoder extends Converter<WithEnum, Map> {
const WithEnumEncoder();
@override
Map convert(WithEnum model) => WithEnumSerializer.toMap(model);
}
class WithEnumDecoder extends Converter<Map, WithEnum> {
const WithEnumDecoder();
@override
WithEnum convert(Map map) => WithEnumSerializer.fromMap(map);
}
class WithEnumSerializer extends Codec<WithEnum, Map> {
const WithEnumSerializer();
@override
get encoder => const WithEnumEncoder();
@override
get decoder => const WithEnumDecoder();
2018-12-08 20:53:49 +00:00
static WithEnum fromMap(Map map) {
return new WithEnum(
type: map['type'] is WithEnumType
? (map['type'] as WithEnumType)
: (map['type'] is int
? WithEnumType.values[map['type'] as int]
2019-04-04 21:40:36 +00:00
: WithEnumType.b),
2018-12-08 20:53:49 +00:00
finalList: map['final_list'] is Iterable
? (map['final_list'] as Iterable).cast<int>().toList()
: null,
imageBytes: map['image_bytes'] is Uint8List
? (map['image_bytes'] as Uint8List)
: (map['image_bytes'] is Iterable<int>
? new Uint8List.fromList(
(map['image_bytes'] as Iterable<int>).toList())
: (map['image_bytes'] is String
? new Uint8List.fromList(
base64.decode(map['image_bytes'] as String))
: null)));
}
2018-12-08 22:31:12 +00:00
static Map<String, dynamic> toMap(_WithEnum model) {
2018-12-08 20:53:49 +00:00
if (model == null) {
return null;
}
return {
'type':
model.type == null ? null : WithEnumType.values.indexOf(model.type),
'final_list': model.finalList,
'image_bytes':
model.imageBytes == null ? null : base64.encode(model.imageBytes)
};
}
}
abstract class WithEnumFields {
2019-04-04 21:40:36 +00:00
static const List<String> allFields = <String>[type, finalList, imageBytes];
2018-12-08 20:53:49 +00:00
static const String type = 'type';
static const String finalList = 'final_list';
static const String imageBytes = 'image_bytes';
}