trphoenix
2018-11-12 29fbfc5dd1d55d189f23eb6d32f000252f92985f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
 
// GENERATED CODE - DO NOT MODIFY BY HAND
 
// **************************************************************************
// _WrappedGenerator
// **************************************************************************
 
// GENERATED CODE - DO NOT MODIFY BY HAND
 
// **************************************************************************
// _NonNullableGenerator
// **************************************************************************
 
// ignore_for_file: hash_and_equals
import 'dart:collection';
 
import 'package:json_annotation/json_annotation.dart';
import 'json_test_common.dart';
 
part 'json_test_example.non_nullable.wrapped.g.dart';
 
@JsonSerializable(
  useWrappers: true,
  nullable: false,
)
class Person {
  final String firstName, middleName, lastName;
  final DateTime dateOfBirth;
  @JsonKey(name: '\$house')
  final Category house;
 
  Order order;
 
  Map<String, Category> houseMap;
  Map<Category, int> categoryCounts;
 
  Person(this.firstName, this.lastName, this.house,
      {this.middleName, this.dateOfBirth});
 
  factory Person.fromJson(Map<String, dynamic> json) => _$PersonFromJson(json);
 
  Map<String, dynamic> toJson() => _$PersonToJson(this);
 
  @override
  bool operator ==(Object other) =>
      other is Person &&
      firstName == other.firstName &&
      middleName == other.middleName &&
      lastName == other.lastName &&
      dateOfBirth == other.dateOfBirth &&
      house == other.house &&
      deepEquals(houseMap, other.houseMap);
}
 
@JsonSerializable(
  useWrappers: true,
  nullable: false,
)
class Order {
  /// Used to test that `disallowNullValues: true` forces `includeIfNull: false`
  @JsonKey(disallowNullValue: true)
  int count;
  bool isRushed;
 
  Duration duration;
 
  @JsonKey(nullable: false)
  final Category category;
  final UnmodifiableListView<Item> items;
  Platform platform;
  Map<String, Platform> altPlatforms;
 
  Uri homepage;
 
  @JsonKey(
      name: 'status_code', defaultValue: StatusCode.success, nullable: true)
  StatusCode statusCode;
 
  @JsonKey(ignore: true)
  String get platformValue => platform?.description;
 
  set platformValue(String value) {
    throw UnimplementedError('not impld');
  }
 
  // Ignored getter without value set in ctor
  int get price => items.fold(0, (total, item) => item.price + total);
 
  @JsonKey(ignore: true)
  bool shouldBeCached;
 
  Order(this.category, [Iterable<Item> items])
      : items = UnmodifiableListView<Item>(
            List<Item>.unmodifiable(items ?? const <Item>[]));
 
  factory Order.fromJson(Map<String, dynamic> json) => _$OrderFromJson(json);
 
  Map<String, dynamic> toJson() => _$OrderToJson(this);
 
  @override
  bool operator ==(Object other) =>
      other is Order &&
      count == other.count &&
      isRushed == other.isRushed &&
      deepEquals(items, other.items) &&
      deepEquals(altPlatforms, other.altPlatforms);
}
 
@JsonSerializable(
  useWrappers: true,
  nullable: false,
)
class Item extends ItemCore {
  @JsonKey(includeIfNull: false, name: 'item-number')
  int itemNumber;
  List<DateTime> saleDates;
  List<int> rates;
 
  Item([int price]) : super(price);
 
  factory Item.fromJson(Map<String, dynamic> json) => _$ItemFromJson(json);
 
  Map<String, dynamic> toJson() => _$ItemToJson(this);
 
  @override
  bool operator ==(Object other) =>
      other is Item &&
      price == other.price &&
      itemNumber == other.itemNumber &&
      deepEquals(saleDates, other.saleDates);
}
 
@JsonSerializable(
  useWrappers: true,
  nullable: false,
)
class Numbers {
  List<int> ints;
  List<num> nums;
  List<double> doubles;
 
  @JsonKey(nullable: false)
  List<double> nnDoubles;
 
  @JsonKey(fromJson: durationFromInt, toJson: durationToInt)
  Duration duration;
 
  @JsonKey(fromJson: dateTimeFromEpochUs, toJson: dateTimeToEpochUs)
  DateTime date;
 
  Numbers();
 
  factory Numbers.fromJson(Map<String, dynamic> json) =>
      _$NumbersFromJson(json);
 
  Map<String, dynamic> toJson() => _$NumbersToJson(this);
 
  @override
  bool operator ==(Object other) =>
      other is Numbers &&
      deepEquals(ints, other.ints) &&
      deepEquals(nums, other.nums) &&
      deepEquals(doubles, other.doubles) &&
      deepEquals(nnDoubles, other.nnDoubles) &&
      deepEquals(duration, other.duration) &&
      deepEquals(date, other.date);
}