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
|
||||
* Generates an `XFields` class with the serialized names of
|
||||
all fields in a model class `X`.
|
||||
* Removed unnecessary named parameters from `XSerializer.fromMap`.
|
||||
|
||||
# 2.0.1
|
||||
* Ensured that `List` is only transformed if
|
||||
|
|
|
@ -128,17 +128,10 @@ class SerializerGenerator extends GeneratorForAnnotation<Serializable> {
|
|||
var buf = new StringBuffer('return new ${ctx.modelClassName}(');
|
||||
int i = 0;
|
||||
|
||||
// Add named parameters
|
||||
for (var field in ctx.fields) {
|
||||
if (ctx.excluded[field.name]?.canDeserialize == false) continue;
|
||||
|
||||
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(', ');
|
||||
|
||||
|
|
|
@ -7,15 +7,7 @@ part of angel_serialize.test.models.author;
|
|||
// **************************************************************************
|
||||
|
||||
abstract class AuthorSerializer {
|
||||
static Author fromMap(Map map,
|
||||
{String id,
|
||||
String name,
|
||||
int age,
|
||||
List<Book> books,
|
||||
Book newestBook,
|
||||
String obscured,
|
||||
DateTime createdAt,
|
||||
DateTime updatedAt}) {
|
||||
static Author fromMap(Map map) {
|
||||
return new Author(
|
||||
id: map['id'],
|
||||
name: map['name'],
|
||||
|
@ -69,11 +61,7 @@ abstract class AuthorFields {
|
|||
}
|
||||
|
||||
abstract class LibrarySerializer {
|
||||
static Library fromMap(Map map,
|
||||
{String id,
|
||||
Map<String, Book> collection,
|
||||
DateTime createdAt,
|
||||
DateTime updatedAt}) {
|
||||
static Library fromMap(Map map) {
|
||||
return new Library(
|
||||
id: map['id'],
|
||||
collection: map['collection'] is Map
|
||||
|
|
|
@ -7,16 +7,7 @@ part of angel_serialize.test.models.book;
|
|||
// **************************************************************************
|
||||
|
||||
abstract class BookSerializer {
|
||||
static Book fromMap(Map map,
|
||||
{String id,
|
||||
String author,
|
||||
String title,
|
||||
String description,
|
||||
int pageCount,
|
||||
List<double> notModels,
|
||||
String camelCaseString,
|
||||
DateTime createdAt,
|
||||
DateTime updatedAt}) {
|
||||
static Book fromMap(Map map) {
|
||||
return new Book(
|
||||
id: map['id'],
|
||||
author: map['author'],
|
||||
|
|
Loading…
Reference in a new issue