Use inflection2
This commit is contained in:
parent
11b3f3f28f
commit
8fc3902955
19 changed files with 592 additions and 45 deletions
|
@ -1,4 +1,4 @@
|
|||
# 2.0.0-dev.8
|
||||
# 2.0.0
|
||||
* `parse` -> `tryParse` where used.
|
||||
|
||||
# 2.0.0-dev.7
|
||||
|
|
|
@ -10,7 +10,7 @@ import 'package:angel_serialize_generator/angel_serialize_generator.dart';
|
|||
import 'package:angel_serialize_generator/build_context.dart';
|
||||
import 'package:angel_serialize_generator/context.dart';
|
||||
import 'package:build/build.dart';
|
||||
import 'package:inflection/inflection.dart';
|
||||
import 'package:inflection2/inflection2.dart';
|
||||
import 'package:recase/recase.dart';
|
||||
import 'package:source_gen/source_gen.dart';
|
||||
|
||||
|
|
|
@ -737,7 +737,8 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
|
|||
var parsedId = prop.property(foreignField.name);
|
||||
|
||||
if (isSpecialId(foreign, field)) {
|
||||
parsedId = (refer('int').property('tryParse').call([parsedId]));
|
||||
parsedId =
|
||||
(refer('int').property('tryParse').call([parsedId]));
|
||||
}
|
||||
|
||||
var cond = prop.notEqualTo(literalNull);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: angel_orm_generator
|
||||
version: 2.0.0-dev.7
|
||||
version: 2.0.0
|
||||
description: Code generators for Angel's ORM. Generates query builder classes.
|
||||
author: Tobe O <thosakwe@gmail.com>
|
||||
homepage: https://github.com/angel-dart/orm
|
||||
|
@ -16,10 +16,7 @@ dependencies:
|
|||
build_config: ^0.3.0
|
||||
code_builder: ^3.0.0
|
||||
dart_style: ^1.0.0
|
||||
inflection:
|
||||
git:
|
||||
url: https://github.com/thosakwe/dart-inflection.git
|
||||
ref: dart2
|
||||
inflection2: ^0.4.2
|
||||
meta: ^1.0.0
|
||||
path: ^1.0.0
|
||||
recase: ^2.0.0
|
||||
|
|
|
@ -21,22 +21,22 @@ builders:
|
|||
targets:
|
||||
_standalone:
|
||||
sources:
|
||||
- test/models/author.dart
|
||||
- test/models/car.dart
|
||||
- test/models/customer.dart
|
||||
- test/models/foot.dart
|
||||
- test/models/fruit.dart
|
||||
- test/models/has_map.dart
|
||||
- test/models/role.dart
|
||||
- test/models/unorthodox.dart
|
||||
- lib/src/models/author.dart
|
||||
- lib/src/models/car.dart
|
||||
- lib/src/models/customer.dart
|
||||
- lib/src/models/foot.dart
|
||||
- lib/src/models/fruit.dart
|
||||
- lib/src/models/has_map.dart
|
||||
- lib/src/models/role.dart
|
||||
- lib/src/models/unorthodox.dart
|
||||
$default:
|
||||
dependencies:
|
||||
- angel_serialize_generator
|
||||
- :_standalone
|
||||
sources:
|
||||
- test/models/book.dart
|
||||
- test/models/has_car.dart
|
||||
- test/models/leg.dart
|
||||
- test/models/order.dart
|
||||
- test/models/tree.dart
|
||||
- test/models/user.dart
|
||||
- lib/src/models/book.dart
|
||||
- lib/src/models/has_car.dart
|
||||
- lib/src/models/leg.dart
|
||||
- lib/src/models/order.dart
|
||||
- lib/src/models/tree.dart
|
||||
- lib/src/models/user.dart
|
|
@ -178,6 +178,11 @@ class Author extends _Author {
|
|||
return hashObjects([id, name, createdAt, updatedAt]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "Author(id=$id, name=$name, createdAt=$createdAt, updatedAt=$updatedAt)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return AuthorSerializer.toMap(this);
|
||||
}
|
||||
|
@ -187,7 +192,29 @@ class Author extends _Author {
|
|||
// SerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class AuthorSerializer {
|
||||
const AuthorSerializer authorSerializer = const AuthorSerializer();
|
||||
|
||||
class AuthorEncoder extends Converter<Author, Map> {
|
||||
const AuthorEncoder();
|
||||
|
||||
@override
|
||||
Map convert(Author model) => AuthorSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class AuthorDecoder extends Converter<Map, Author> {
|
||||
const AuthorDecoder();
|
||||
|
||||
@override
|
||||
Author convert(Map map) => AuthorSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class AuthorSerializer extends Codec<Author, Map> {
|
||||
const AuthorSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const AuthorEncoder();
|
||||
@override
|
||||
get decoder => const AuthorDecoder();
|
||||
static Author fromMap(Map map) {
|
||||
return new Author(
|
||||
id: map['id'] as String,
|
||||
|
|
|
@ -243,6 +243,11 @@ class Book extends _Book {
|
|||
return hashObjects([id, author, partnerAuthor, name, createdAt, updatedAt]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "Book(id=$id, author=$author, partnerAuthor=$partnerAuthor, name=$name, createdAt=$createdAt, updatedAt=$updatedAt)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return BookSerializer.toMap(this);
|
||||
}
|
||||
|
@ -252,7 +257,29 @@ class Book extends _Book {
|
|||
// SerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class BookSerializer {
|
||||
const BookSerializer bookSerializer = const BookSerializer();
|
||||
|
||||
class BookEncoder extends Converter<Book, Map> {
|
||||
const BookEncoder();
|
||||
|
||||
@override
|
||||
Map convert(Book model) => BookSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class BookDecoder extends Converter<Map, Book> {
|
||||
const BookDecoder();
|
||||
|
||||
@override
|
||||
Book convert(Map map) => BookSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class BookSerializer extends Codec<Book, Map> {
|
||||
const BookSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const BookEncoder();
|
||||
@override
|
||||
get decoder => const BookDecoder();
|
||||
static Book fromMap(Map map) {
|
||||
return new Book(
|
||||
id: map['id'] as String,
|
||||
|
|
|
@ -261,6 +261,11 @@ class Car extends _Car {
|
|||
]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "Car(id=$id, make=$make, description=$description, familyFriendly=$familyFriendly, recalledAt=$recalledAt, createdAt=$createdAt, updatedAt=$updatedAt)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return CarSerializer.toMap(this);
|
||||
}
|
||||
|
@ -270,7 +275,29 @@ class Car extends _Car {
|
|||
// SerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class CarSerializer {
|
||||
const CarSerializer carSerializer = const CarSerializer();
|
||||
|
||||
class CarEncoder extends Converter<Car, Map> {
|
||||
const CarEncoder();
|
||||
|
||||
@override
|
||||
Map convert(Car model) => CarSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class CarDecoder extends Converter<Map, Car> {
|
||||
const CarDecoder();
|
||||
|
||||
@override
|
||||
Car convert(Map map) => CarSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class CarSerializer extends Codec<Car, Map> {
|
||||
const CarSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const CarEncoder();
|
||||
@override
|
||||
get decoder => const CarDecoder();
|
||||
static Car fromMap(Map map) {
|
||||
return new Car(
|
||||
id: map['id'] as String,
|
||||
|
|
|
@ -159,6 +159,11 @@ class Customer extends _Customer {
|
|||
return hashObjects([id, createdAt, updatedAt]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "Customer(id=$id, createdAt=$createdAt, updatedAt=$updatedAt)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return CustomerSerializer.toMap(this);
|
||||
}
|
||||
|
@ -168,7 +173,29 @@ class Customer extends _Customer {
|
|||
// SerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class CustomerSerializer {
|
||||
const CustomerSerializer customerSerializer = const CustomerSerializer();
|
||||
|
||||
class CustomerEncoder extends Converter<Customer, Map> {
|
||||
const CustomerEncoder();
|
||||
|
||||
@override
|
||||
Map convert(Customer model) => CustomerSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class CustomerDecoder extends Converter<Map, Customer> {
|
||||
const CustomerDecoder();
|
||||
|
||||
@override
|
||||
Customer convert(Map map) => CustomerSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class CustomerSerializer extends Codec<Customer, Map> {
|
||||
const CustomerSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const CustomerEncoder();
|
||||
@override
|
||||
get decoder => const CustomerDecoder();
|
||||
static Customer fromMap(Map map) {
|
||||
return new Customer(
|
||||
id: map['id'] as String,
|
||||
|
|
|
@ -70,7 +70,7 @@ class FootQuery extends Query<Foot, FootQueryWhere> {
|
|||
var model = Foot(
|
||||
id: row[0].toString(),
|
||||
legId: (row[1] as int),
|
||||
nToes: double.parse(row[2].toString()),
|
||||
nToes: double.tryParse(row[2].toString()),
|
||||
createdAt: (row[3] as DateTime),
|
||||
updatedAt: (row[4] as DateTime));
|
||||
return model;
|
||||
|
@ -123,7 +123,7 @@ class FootQueryValues extends MapQueryValues {
|
|||
|
||||
set legId(int value) => values['leg_id'] = value;
|
||||
double get nToes {
|
||||
return double.parse((values['n_toes'] as String));
|
||||
return double.tryParse((values['n_toes'] as String));
|
||||
}
|
||||
|
||||
set nToes(double value) => values['n_toes'] = value.toString();
|
||||
|
@ -196,6 +196,11 @@ class Foot extends _Foot {
|
|||
return hashObjects([id, legId, nToes, createdAt, updatedAt]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "Foot(id=$id, legId=$legId, nToes=$nToes, createdAt=$createdAt, updatedAt=$updatedAt)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return FootSerializer.toMap(this);
|
||||
}
|
||||
|
@ -205,7 +210,29 @@ class Foot extends _Foot {
|
|||
// SerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class FootSerializer {
|
||||
const FootSerializer footSerializer = const FootSerializer();
|
||||
|
||||
class FootEncoder extends Converter<Foot, Map> {
|
||||
const FootEncoder();
|
||||
|
||||
@override
|
||||
Map convert(Foot model) => FootSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class FootDecoder extends Converter<Map, Foot> {
|
||||
const FootDecoder();
|
||||
|
||||
@override
|
||||
Foot convert(Map map) => FootSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class FootSerializer extends Codec<Foot, Map> {
|
||||
const FootSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const FootEncoder();
|
||||
@override
|
||||
get decoder => const FootDecoder();
|
||||
static Foot fromMap(Map map) {
|
||||
return new Foot(
|
||||
id: map['id'] as String,
|
||||
|
|
|
@ -197,6 +197,11 @@ class Fruit extends _Fruit {
|
|||
return hashObjects([id, treeId, commonName, createdAt, updatedAt]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "Fruit(id=$id, treeId=$treeId, commonName=$commonName, createdAt=$createdAt, updatedAt=$updatedAt)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return FruitSerializer.toMap(this);
|
||||
}
|
||||
|
@ -206,7 +211,29 @@ class Fruit extends _Fruit {
|
|||
// SerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class FruitSerializer {
|
||||
const FruitSerializer fruitSerializer = const FruitSerializer();
|
||||
|
||||
class FruitEncoder extends Converter<Fruit, Map> {
|
||||
const FruitEncoder();
|
||||
|
||||
@override
|
||||
Map convert(Fruit model) => FruitSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class FruitDecoder extends Converter<Map, Fruit> {
|
||||
const FruitDecoder();
|
||||
|
||||
@override
|
||||
Fruit convert(Map map) => FruitSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class FruitSerializer extends Codec<Fruit, Map> {
|
||||
const FruitSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const FruitEncoder();
|
||||
@override
|
||||
get decoder => const FruitDecoder();
|
||||
static Fruit fromMap(Map map) {
|
||||
return new Fruit(
|
||||
id: map['id'] as String,
|
||||
|
|
|
@ -176,6 +176,11 @@ class HasCar extends _HasCar {
|
|||
return hashObjects([id, type, createdAt, updatedAt]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "HasCar(id=$id, type=$type, createdAt=$createdAt, updatedAt=$updatedAt)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return HasCarSerializer.toMap(this);
|
||||
}
|
||||
|
@ -185,7 +190,29 @@ class HasCar extends _HasCar {
|
|||
// SerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class HasCarSerializer {
|
||||
const HasCarSerializer hasCarSerializer = const HasCarSerializer();
|
||||
|
||||
class HasCarEncoder extends Converter<HasCar, Map> {
|
||||
const HasCarEncoder();
|
||||
|
||||
@override
|
||||
Map convert(HasCar model) => HasCarSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class HasCarDecoder extends Converter<Map, HasCar> {
|
||||
const HasCarDecoder();
|
||||
|
||||
@override
|
||||
HasCar convert(Map map) => HasCarSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class HasCarSerializer extends Codec<HasCar, Map> {
|
||||
const HasCarSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const HasCarEncoder();
|
||||
@override
|
||||
get decoder => const HasCarDecoder();
|
||||
static HasCar fromMap(Map map) {
|
||||
if (map['type'] == null) {
|
||||
throw new FormatException("Missing required field 'type' on HasCar.");
|
||||
|
|
|
@ -1,15 +1,24 @@
|
|||
import 'dart:convert';
|
||||
import 'package:angel_migration/angel_migration.dart';
|
||||
import 'package:angel_model/angel_model.dart';
|
||||
import 'package:angel_orm/angel_orm.dart';
|
||||
import 'package:angel_serialize/angel_serialize.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
part 'has_map.g.dart';
|
||||
|
||||
String _boolToCustom(bool v) => v ? 'yes' : 'no';
|
||||
bool _customToBool(v) => v == 'yes';
|
||||
|
||||
@orm
|
||||
@serializable
|
||||
abstract class _HasMap {
|
||||
Map get value;
|
||||
|
||||
List get list;
|
||||
|
||||
// TODO: Support custom serializers
|
||||
// @SerializableField(
|
||||
// serializer: #_boolToCustom,
|
||||
// deserializer: #_customToBool,
|
||||
// serializesTo: String)
|
||||
// bool get customBool;
|
||||
}
|
||||
|
|
|
@ -145,6 +145,11 @@ class HasMap implements _HasMap {
|
|||
return hashObjects([value, list]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "HasMap(value=$value, list=$list)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return HasMapSerializer.toMap(this);
|
||||
}
|
||||
|
@ -154,7 +159,29 @@ class HasMap implements _HasMap {
|
|||
// SerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class HasMapSerializer {
|
||||
const HasMapSerializer hasMapSerializer = const HasMapSerializer();
|
||||
|
||||
class HasMapEncoder extends Converter<HasMap, Map> {
|
||||
const HasMapEncoder();
|
||||
|
||||
@override
|
||||
Map convert(HasMap model) => HasMapSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class HasMapDecoder extends Converter<Map, HasMap> {
|
||||
const HasMapDecoder();
|
||||
|
||||
@override
|
||||
HasMap convert(Map map) => HasMapSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class HasMapSerializer extends Codec<HasMap, Map> {
|
||||
const HasMapSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const HasMapEncoder();
|
||||
@override
|
||||
get decoder => const HasMapDecoder();
|
||||
static HasMap fromMap(Map map) {
|
||||
return new HasMap(
|
||||
value: map['value'] is Map
|
||||
|
|
|
@ -197,6 +197,11 @@ class Leg extends _Leg {
|
|||
return hashObjects([id, foot, name, createdAt, updatedAt]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "Leg(id=$id, foot=$foot, name=$name, createdAt=$createdAt, updatedAt=$updatedAt)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return LegSerializer.toMap(this);
|
||||
}
|
||||
|
@ -206,7 +211,29 @@ class Leg extends _Leg {
|
|||
// SerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class LegSerializer {
|
||||
const LegSerializer legSerializer = const LegSerializer();
|
||||
|
||||
class LegEncoder extends Converter<Leg, Map> {
|
||||
const LegEncoder();
|
||||
|
||||
@override
|
||||
Map convert(Leg model) => LegSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class LegDecoder extends Converter<Map, Leg> {
|
||||
const LegDecoder();
|
||||
|
||||
@override
|
||||
Leg convert(Map map) => LegSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class LegSerializer extends Codec<Leg, Map> {
|
||||
const LegSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const LegEncoder();
|
||||
@override
|
||||
get decoder => const LegDecoder();
|
||||
static Leg fromMap(Map map) {
|
||||
return new Leg(
|
||||
id: map['id'] as String,
|
||||
|
|
|
@ -262,6 +262,11 @@ class Order extends _Order {
|
|||
[id, customer, employeeId, orderDate, shipperId, createdAt, updatedAt]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "Order(id=$id, customer=$customer, employeeId=$employeeId, orderDate=$orderDate, shipperId=$shipperId, createdAt=$createdAt, updatedAt=$updatedAt)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return OrderSerializer.toMap(this);
|
||||
}
|
||||
|
@ -271,7 +276,29 @@ class Order extends _Order {
|
|||
// SerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class OrderSerializer {
|
||||
const OrderSerializer orderSerializer = const OrderSerializer();
|
||||
|
||||
class OrderEncoder extends Converter<Order, Map> {
|
||||
const OrderEncoder();
|
||||
|
||||
@override
|
||||
Map convert(Order model) => OrderSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class OrderDecoder extends Converter<Map, Order> {
|
||||
const OrderDecoder();
|
||||
|
||||
@override
|
||||
Order convert(Map map) => OrderSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class OrderSerializer extends Codec<Order, Map> {
|
||||
const OrderSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const OrderEncoder();
|
||||
@override
|
||||
get decoder => const OrderDecoder();
|
||||
static Order fromMap(Map map) {
|
||||
return new Order(
|
||||
id: map['id'] as String,
|
||||
|
|
|
@ -260,6 +260,11 @@ class Tree extends _Tree {
|
|||
return hashObjects([id, rings, fruits, createdAt, updatedAt]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "Tree(id=$id, rings=$rings, fruits=$fruits, createdAt=$createdAt, updatedAt=$updatedAt)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return TreeSerializer.toMap(this);
|
||||
}
|
||||
|
@ -269,7 +274,29 @@ class Tree extends _Tree {
|
|||
// SerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class TreeSerializer {
|
||||
const TreeSerializer treeSerializer = const TreeSerializer();
|
||||
|
||||
class TreeEncoder extends Converter<Tree, Map> {
|
||||
const TreeEncoder();
|
||||
|
||||
@override
|
||||
Map convert(Tree model) => TreeSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class TreeDecoder extends Converter<Map, Tree> {
|
||||
const TreeDecoder();
|
||||
|
||||
@override
|
||||
Tree convert(Map map) => TreeSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class TreeSerializer extends Codec<Tree, Map> {
|
||||
const TreeSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const TreeEncoder();
|
||||
@override
|
||||
get decoder => const TreeDecoder();
|
||||
static Tree fromMap(Map map) {
|
||||
return new Tree(
|
||||
id: map['id'] as String,
|
||||
|
|
|
@ -839,6 +839,11 @@ class Unorthodox implements _Unorthodox {
|
|||
return hashObjects([name]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "Unorthodox(name=$name)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return UnorthodoxSerializer.toMap(this);
|
||||
}
|
||||
|
@ -898,6 +903,11 @@ class WeirdJoin implements _WeirdJoin {
|
|||
return hashObjects([id, unorthodox, song, numbas, foos]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "WeirdJoin(id=$id, unorthodox=$unorthodox, song=$song, numbas=$numbas, foos=$foos)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return WeirdJoinSerializer.toMap(this);
|
||||
}
|
||||
|
@ -950,6 +960,11 @@ class Song extends _Song {
|
|||
return hashObjects([id, weirdJoinId, title, createdAt, updatedAt]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "Song(id=$id, weirdJoinId=$weirdJoinId, title=$title, createdAt=$createdAt, updatedAt=$updatedAt)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return SongSerializer.toMap(this);
|
||||
}
|
||||
|
@ -978,6 +993,11 @@ class Numba extends _Numba {
|
|||
return hashObjects([i, parent]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "Numba(i=$i, parent=$parent)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return NumbaSerializer.toMap(this);
|
||||
}
|
||||
|
@ -1010,6 +1030,11 @@ class Foo implements _Foo {
|
|||
return hashObjects([bar, weirdJoins]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "Foo(bar=$bar, weirdJoins=$weirdJoins)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return FooSerializer.toMap(this);
|
||||
}
|
||||
|
@ -1041,6 +1066,11 @@ class FooPivot implements _FooPivot {
|
|||
return hashObjects([weirdJoin, foo]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "FooPivot(weirdJoin=$weirdJoin, foo=$foo)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return FooPivotSerializer.toMap(this);
|
||||
}
|
||||
|
@ -1050,7 +1080,29 @@ class FooPivot implements _FooPivot {
|
|||
// SerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class UnorthodoxSerializer {
|
||||
const UnorthodoxSerializer unorthodoxSerializer = const UnorthodoxSerializer();
|
||||
|
||||
class UnorthodoxEncoder extends Converter<Unorthodox, Map> {
|
||||
const UnorthodoxEncoder();
|
||||
|
||||
@override
|
||||
Map convert(Unorthodox model) => UnorthodoxSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class UnorthodoxDecoder extends Converter<Map, Unorthodox> {
|
||||
const UnorthodoxDecoder();
|
||||
|
||||
@override
|
||||
Unorthodox convert(Map map) => UnorthodoxSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class UnorthodoxSerializer extends Codec<Unorthodox, Map> {
|
||||
const UnorthodoxSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const UnorthodoxEncoder();
|
||||
@override
|
||||
get decoder => const UnorthodoxDecoder();
|
||||
static Unorthodox fromMap(Map map) {
|
||||
return new Unorthodox(name: map['name'] as String);
|
||||
}
|
||||
|
@ -1069,7 +1121,29 @@ abstract class UnorthodoxFields {
|
|||
static const String name = 'name';
|
||||
}
|
||||
|
||||
abstract class WeirdJoinSerializer {
|
||||
const WeirdJoinSerializer weirdJoinSerializer = const WeirdJoinSerializer();
|
||||
|
||||
class WeirdJoinEncoder extends Converter<WeirdJoin, Map> {
|
||||
const WeirdJoinEncoder();
|
||||
|
||||
@override
|
||||
Map convert(WeirdJoin model) => WeirdJoinSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class WeirdJoinDecoder extends Converter<Map, WeirdJoin> {
|
||||
const WeirdJoinDecoder();
|
||||
|
||||
@override
|
||||
WeirdJoin convert(Map map) => WeirdJoinSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class WeirdJoinSerializer extends Codec<WeirdJoin, Map> {
|
||||
const WeirdJoinSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const WeirdJoinEncoder();
|
||||
@override
|
||||
get decoder => const WeirdJoinDecoder();
|
||||
static WeirdJoin fromMap(Map map) {
|
||||
return new WeirdJoin(
|
||||
id: map['id'] as int,
|
||||
|
@ -1127,7 +1201,29 @@ abstract class WeirdJoinFields {
|
|||
static const String foos = 'foos';
|
||||
}
|
||||
|
||||
abstract class SongSerializer {
|
||||
const SongSerializer songSerializer = const SongSerializer();
|
||||
|
||||
class SongEncoder extends Converter<Song, Map> {
|
||||
const SongEncoder();
|
||||
|
||||
@override
|
||||
Map convert(Song model) => SongSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class SongDecoder extends Converter<Map, Song> {
|
||||
const SongDecoder();
|
||||
|
||||
@override
|
||||
Song convert(Map map) => SongSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class SongSerializer extends Codec<Song, Map> {
|
||||
const SongSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const SongEncoder();
|
||||
@override
|
||||
get decoder => const SongDecoder();
|
||||
static Song fromMap(Map map) {
|
||||
return new Song(
|
||||
id: map['id'] as String,
|
||||
|
@ -1179,7 +1275,29 @@ abstract class SongFields {
|
|||
static const String updatedAt = 'updated_at';
|
||||
}
|
||||
|
||||
abstract class NumbaSerializer {
|
||||
const NumbaSerializer numbaSerializer = const NumbaSerializer();
|
||||
|
||||
class NumbaEncoder extends Converter<Numba, Map> {
|
||||
const NumbaEncoder();
|
||||
|
||||
@override
|
||||
Map convert(Numba model) => NumbaSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class NumbaDecoder extends Converter<Map, Numba> {
|
||||
const NumbaDecoder();
|
||||
|
||||
@override
|
||||
Numba convert(Map map) => NumbaSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class NumbaSerializer extends Codec<Numba, Map> {
|
||||
const NumbaSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const NumbaEncoder();
|
||||
@override
|
||||
get decoder => const NumbaDecoder();
|
||||
static Numba fromMap(Map map) {
|
||||
return new Numba(i: map['i'] as int, parent: map['parent'] as int);
|
||||
}
|
||||
|
@ -1200,7 +1318,29 @@ abstract class NumbaFields {
|
|||
static const String parent = 'parent';
|
||||
}
|
||||
|
||||
abstract class FooSerializer {
|
||||
const FooSerializer fooSerializer = const FooSerializer();
|
||||
|
||||
class FooEncoder extends Converter<Foo, Map> {
|
||||
const FooEncoder();
|
||||
|
||||
@override
|
||||
Map convert(Foo model) => FooSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class FooDecoder extends Converter<Map, Foo> {
|
||||
const FooDecoder();
|
||||
|
||||
@override
|
||||
Foo convert(Map map) => FooSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class FooSerializer extends Codec<Foo, Map> {
|
||||
const FooSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const FooEncoder();
|
||||
@override
|
||||
get decoder => const FooDecoder();
|
||||
static Foo fromMap(Map map) {
|
||||
return new Foo(
|
||||
bar: map['bar'] as String,
|
||||
|
@ -1232,7 +1372,29 @@ abstract class FooFields {
|
|||
static const String weirdJoins = 'weird_joins';
|
||||
}
|
||||
|
||||
abstract class FooPivotSerializer {
|
||||
const FooPivotSerializer fooPivotSerializer = const FooPivotSerializer();
|
||||
|
||||
class FooPivotEncoder extends Converter<FooPivot, Map> {
|
||||
const FooPivotEncoder();
|
||||
|
||||
@override
|
||||
Map convert(FooPivot model) => FooPivotSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class FooPivotDecoder extends Converter<Map, FooPivot> {
|
||||
const FooPivotDecoder();
|
||||
|
||||
@override
|
||||
FooPivot convert(Map map) => FooPivotSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class FooPivotSerializer extends Codec<FooPivot, Map> {
|
||||
const FooPivotSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const FooPivotEncoder();
|
||||
@override
|
||||
get decoder => const FooPivotDecoder();
|
||||
static FooPivot fromMap(Map map) {
|
||||
return new FooPivot(
|
||||
weirdJoin: map['weird_join'] != null
|
||||
|
|
|
@ -635,6 +635,11 @@ class User extends _User {
|
|||
[id, username, password, email, roles, createdAt, updatedAt]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "User(id=$id, username=$username, password=$password, email=$email, roles=$roles, createdAt=$createdAt, updatedAt=$updatedAt)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return UserSerializer.toMap(this);
|
||||
}
|
||||
|
@ -663,6 +668,11 @@ class RoleUser implements _RoleUser {
|
|||
return hashObjects([role, user]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "RoleUser(role=$role, user=$user)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return RoleUserSerializer.toMap(this);
|
||||
}
|
||||
|
@ -717,6 +727,11 @@ class Role extends _Role {
|
|||
return hashObjects([id, name, users, createdAt, updatedAt]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return "Role(id=$id, name=$name, users=$users, createdAt=$createdAt, updatedAt=$updatedAt)";
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return RoleSerializer.toMap(this);
|
||||
}
|
||||
|
@ -726,7 +741,29 @@ class Role extends _Role {
|
|||
// SerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class UserSerializer {
|
||||
const UserSerializer userSerializer = const UserSerializer();
|
||||
|
||||
class UserEncoder extends Converter<User, Map> {
|
||||
const UserEncoder();
|
||||
|
||||
@override
|
||||
Map convert(User model) => UserSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class UserDecoder extends Converter<Map, User> {
|
||||
const UserDecoder();
|
||||
|
||||
@override
|
||||
User convert(Map map) => UserSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class UserSerializer extends Codec<User, Map> {
|
||||
const UserSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const UserEncoder();
|
||||
@override
|
||||
get decoder => const UserDecoder();
|
||||
static User fromMap(Map map) {
|
||||
return new User(
|
||||
id: map['id'] as String,
|
||||
|
@ -793,7 +830,29 @@ abstract class UserFields {
|
|||
static const String updatedAt = 'updated_at';
|
||||
}
|
||||
|
||||
abstract class RoleUserSerializer {
|
||||
const RoleUserSerializer roleUserSerializer = const RoleUserSerializer();
|
||||
|
||||
class RoleUserEncoder extends Converter<RoleUser, Map> {
|
||||
const RoleUserEncoder();
|
||||
|
||||
@override
|
||||
Map convert(RoleUser model) => RoleUserSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class RoleUserDecoder extends Converter<Map, RoleUser> {
|
||||
const RoleUserDecoder();
|
||||
|
||||
@override
|
||||
RoleUser convert(Map map) => RoleUserSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class RoleUserSerializer extends Codec<RoleUser, Map> {
|
||||
const RoleUserSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const RoleUserEncoder();
|
||||
@override
|
||||
get decoder => const RoleUserDecoder();
|
||||
static RoleUser fromMap(Map map) {
|
||||
return new RoleUser(
|
||||
role: map['role'] != null
|
||||
|
@ -823,7 +882,29 @@ abstract class RoleUserFields {
|
|||
static const String user = 'user';
|
||||
}
|
||||
|
||||
abstract class RoleSerializer {
|
||||
const RoleSerializer roleSerializer = const RoleSerializer();
|
||||
|
||||
class RoleEncoder extends Converter<Role, Map> {
|
||||
const RoleEncoder();
|
||||
|
||||
@override
|
||||
Map convert(Role model) => RoleSerializer.toMap(model);
|
||||
}
|
||||
|
||||
class RoleDecoder extends Converter<Map, Role> {
|
||||
const RoleDecoder();
|
||||
|
||||
@override
|
||||
Role convert(Map map) => RoleSerializer.fromMap(map);
|
||||
}
|
||||
|
||||
class RoleSerializer extends Codec<Role, Map> {
|
||||
const RoleSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const RoleEncoder();
|
||||
@override
|
||||
get decoder => const RoleDecoder();
|
||||
static Role fromMap(Map map) {
|
||||
return new Role(
|
||||
id: map['id'] as String,
|
||||
|
|
Loading…
Reference in a new issue