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

97 lines
2.8 KiB
Dart
Raw Normal View History

// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'game_pad.dart';
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
2018-07-11 15:49:46 +00:00
class Gamepad extends _Gamepad {
2019-04-04 21:40:36 +00:00
Gamepad(
{@required List<dynamic> buttons,
@required Map<String, dynamic> dynamicMap})
2018-07-11 15:49:46 +00:00
: this.buttons = new List.unmodifiable(buttons ?? []),
this.dynamicMap = new Map.unmodifiable(dynamicMap ?? {});
@override
2019-04-04 21:40:36 +00:00
final List<dynamic> buttons;
@override
final Map<String, dynamic> dynamicMap;
2019-04-04 21:40:36 +00:00
Gamepad copyWith({List<dynamic> buttons, Map<String, dynamic> dynamicMap}) {
return new Gamepad(
buttons: buttons ?? this.buttons,
dynamicMap: dynamicMap ?? this.dynamicMap);
}
bool operator ==(other) {
return other is _Gamepad &&
2019-04-04 21:40:36 +00:00
const ListEquality<dynamic>(const DefaultEquality())
.equals(other.buttons, buttons) &&
const MapEquality<String, dynamic>(
keys: const DefaultEquality<String>(),
values: const DefaultEquality())
.equals(other.dynamicMap, dynamicMap);
}
2018-11-03 07:36:59 +00:00
@override
int get hashCode {
return hashObjects([buttons, dynamicMap]);
}
Map<String, dynamic> toJson() {
return GamepadSerializer.toMap(this);
}
}
2018-12-08 20:53:49 +00:00
// **************************************************************************
// SerializerGenerator
// **************************************************************************
abstract class GamepadSerializer {
static Gamepad fromMap(Map map) {
2019-04-04 21:40:36 +00:00
if (map['buttons'] == null) {
throw new FormatException("Missing required field 'buttons' on Gamepad.");
}
if (map['dynamic_map'] == null) {
throw new FormatException(
"Missing required field 'dynamic_map' on Gamepad.");
}
2018-12-08 20:53:49 +00:00
return new Gamepad(
buttons: map['buttons'] is Iterable
2019-04-04 21:40:36 +00:00
? (map['buttons'] as Iterable).cast<dynamic>().toList()
2018-12-08 20:53:49 +00:00
: null,
dynamicMap: map['dynamic_map'] is Map
? (map['dynamic_map'] as Map).cast<String, dynamic>()
: null);
}
2018-12-08 22:31:12 +00:00
static Map<String, dynamic> toMap(_Gamepad model) {
2018-12-08 20:53:49 +00:00
if (model == null) {
return null;
}
2019-04-04 21:40:36 +00:00
if (model.buttons == null) {
throw new FormatException("Missing required field 'buttons' on Gamepad.");
}
if (model.dynamicMap == null) {
throw new FormatException(
"Missing required field 'dynamic_map' on Gamepad.");
}
return {'buttons': model.buttons, 'dynamic_map': model.dynamicMap};
2018-12-08 20:53:49 +00:00
}
}
abstract class GamepadFields {
2019-04-04 21:40:36 +00:00
static const List<String> allFields = <String>[buttons, dynamicMap];
2018-12-08 20:53:49 +00:00
static const String buttons = 'buttons';
static const String dynamicMap = 'dynamic_map';
}