Remove unnecessary named parameters
This commit is contained in:
parent
51bf0c2329
commit
31006f54e2
4 changed files with 4 additions and 31 deletions
|
@ -1,6 +1,7 @@
|
||||||
# 2.0.2
|
# 2.0.2
|
||||||
* Generates an `XFields` class with the serialized names of
|
* Generates an `XFields` class with the serialized names of
|
||||||
all fields in a model class `X`.
|
all fields in a model class `X`.
|
||||||
|
* Removed unnecessary named parameters from `XSerializer.fromMap`.
|
||||||
|
|
||||||
# 2.0.1
|
# 2.0.1
|
||||||
* Ensured that `List` is only transformed if
|
* Ensured that `List` is only transformed if
|
||||||
|
|
|
@ -128,17 +128,10 @@ class SerializerGenerator extends GeneratorForAnnotation<Serializable> {
|
||||||
var buf = new StringBuffer('return new ${ctx.modelClassName}(');
|
var buf = new StringBuffer('return new ${ctx.modelClassName}(');
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
// Add named parameters
|
|
||||||
for (var field in ctx.fields) {
|
for (var field in ctx.fields) {
|
||||||
if (ctx.excluded[field.name]?.canDeserialize == false) continue;
|
if (ctx.excluded[field.name]?.canDeserialize == false) continue;
|
||||||
|
|
||||||
var alias = ctx.resolveFieldName(field.name);
|
var alias = ctx.resolveFieldName(field.name);
|
||||||
method.optionalParameters.add(new Parameter((b) {
|
|
||||||
b
|
|
||||||
..name = field.name
|
|
||||||
..named = true
|
|
||||||
..type = convertTypeReference(field.type);
|
|
||||||
}));
|
|
||||||
|
|
||||||
if (i++ > 0) buf.write(', ');
|
if (i++ > 0) buf.write(', ');
|
||||||
|
|
||||||
|
|
|
@ -7,15 +7,7 @@ part of angel_serialize.test.models.author;
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
abstract class AuthorSerializer {
|
abstract class AuthorSerializer {
|
||||||
static Author fromMap(Map map,
|
static Author fromMap(Map map) {
|
||||||
{String id,
|
|
||||||
String name,
|
|
||||||
int age,
|
|
||||||
List<Book> books,
|
|
||||||
Book newestBook,
|
|
||||||
String obscured,
|
|
||||||
DateTime createdAt,
|
|
||||||
DateTime updatedAt}) {
|
|
||||||
return new Author(
|
return new Author(
|
||||||
id: map['id'],
|
id: map['id'],
|
||||||
name: map['name'],
|
name: map['name'],
|
||||||
|
@ -69,11 +61,7 @@ abstract class AuthorFields {
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class LibrarySerializer {
|
abstract class LibrarySerializer {
|
||||||
static Library fromMap(Map map,
|
static Library fromMap(Map map) {
|
||||||
{String id,
|
|
||||||
Map<String, Book> collection,
|
|
||||||
DateTime createdAt,
|
|
||||||
DateTime updatedAt}) {
|
|
||||||
return new Library(
|
return new Library(
|
||||||
id: map['id'],
|
id: map['id'],
|
||||||
collection: map['collection'] is Map
|
collection: map['collection'] is Map
|
||||||
|
|
|
@ -7,16 +7,7 @@ part of angel_serialize.test.models.book;
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
abstract class BookSerializer {
|
abstract class BookSerializer {
|
||||||
static Book fromMap(Map map,
|
static Book fromMap(Map map) {
|
||||||
{String id,
|
|
||||||
String author,
|
|
||||||
String title,
|
|
||||||
String description,
|
|
||||||
int pageCount,
|
|
||||||
List<double> notModels,
|
|
||||||
String camelCaseString,
|
|
||||||
DateTime createdAt,
|
|
||||||
DateTime updatedAt}) {
|
|
||||||
return new Book(
|
return new Book(
|
||||||
id: map['id'],
|
id: map['id'],
|
||||||
author: map['author'],
|
author: map['author'],
|
||||||
|
|
Loading…
Reference in a new issue