Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added case insensitive fields mapping #18

Merged
merged 35 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
19aeca2
Added case sensivity handling
KamilMrowiec Jun 23, 2021
20bb270
Added tests
KamilMrowiec Jun 23, 2021
33e33bc
Added example
KamilMrowiec Jun 23, 2021
a85264d
Added checking for duplicated fields in case insensitive mapper
KamilMrowiec Jun 24, 2021
e332612
Added documentation
KamilMrowiec Jun 24, 2021
eced6cd
Added more tests
KamilMrowiec Jun 24, 2021
31d882c
Updated example
KamilMrowiec Jun 24, 2021
a9a90b7
Merge commit 'c8e1c2022e3e2ba76a34fa547a28bbeac2327737' into feature/…
KamilMrowiec Jun 24, 2021
f36f581
Merge pull request #1 from Antriadus/feature/case_insenstive
Antriadus Jun 24, 2021
199f456
Updated versions
KamilMrowiec Jun 24, 2021
cb79491
Updated CHANGELOG.md
KamilMrowiec Jun 24, 2021
14708ab
Updated path to example
KamilMrowiec Jun 24, 2021
ce33f30
Repaired packege sources
KamilMrowiec Jun 29, 2021
f93185f
Merge branch 'master' of https://github.com/smotastic/smartstruct int…
KamilMrowiec Jun 29, 2021
2ee0a5a
Merge branch 'smotastic-master'
KamilMrowiec Jun 29, 2021
22dda7f
Added CustomMapping annotation
KamilMrowiec Jun 30, 2021
c0f9207
First working version of custom mapping
KamilMrowiec Jun 30, 2021
da1e908
Working on mapper generator
KamilMrowiec Jul 1, 2021
f171927
Repaired case_senstive example
KamilMrowiec Jul 1, 2021
3a68627
Added custom mapping test
KamilMrowiec Jul 1, 2021
02ed035
Connected custom mapping tests
KamilMrowiec Jul 1, 2021
da6a2de
Added custom mapping example
KamilMrowiec Jul 1, 2021
97da9e7
Added string list extensions
KamilMrowiec Jul 1, 2021
106c09e
Repaired custom_mapping tests
KamilMrowiec Jul 1, 2021
37a85b6
Repaired custom mapping
KamilMrowiec Jul 1, 2021
fcad6a1
Updated custom_mapping test
KamilMrowiec Jul 1, 2021
fbd6500
Added examples
KamilMrowiec Jul 1, 2021
ca7600a
Merge branch 'master' of https://github.com/smotastic/smartstruct int…
KamilMrowiec Jul 1, 2021
ebe8005
Merge branch 'master' of https://github.com/smotastic/smartstruct
KamilMrowiec Jul 1, 2021
35cd7b9
Merge commit 'ebe80053da6f8edbb588e82a9bd585dc9e70d8cf' into feature/…
KamilMrowiec Jul 1, 2021
79dd55e
Merge pull request #4 from Antriadus/feature/custom-field
Antriadus Jul 1, 2021
7c0b80e
Repaired test
KamilMrowiec Jul 1, 2021
657a1fc
Removed unecessary StringListExtensions
KamilMrowiec Jul 1, 2021
e223a29
Updated examples
KamilMrowiec Jul 2, 2021
de3a740
Merge branch 'master' into master
smotastic Aug 18, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 60 additions & 60 deletions example/.packages
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,64 @@
#
# For more info see: https://dart.dev/go/dot-packages-deprecation
#
# Generated by pub on 2021-07-25 13:05:26.117749.
_fe_analyzer_shared:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/_fe_analyzer_shared-22.0.0/lib/
analyzer:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/analyzer-1.7.1/lib/
args:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/args-2.1.1/lib/
async:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/async-2.7.0/lib/
build:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/build-2.0.2/lib/
build_config:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/build_config-1.0.0/lib/
build_daemon:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/build_daemon-3.0.0/lib/
build_resolvers:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/build_resolvers-2.0.3/lib/
build_runner:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/build_runner-2.0.4/lib/
build_runner_core:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/build_runner_core-7.0.0/lib/
built_collection:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/built_collection-5.0.0/lib/
built_value:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/built_value-8.0.6/lib/
charcode:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/charcode-1.2.0/lib/
checked_yaml:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/checked_yaml-2.0.1/lib/
cli_util:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/cli_util-0.3.0/lib/
code_builder:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/code_builder-4.0.0/lib/
collection:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/collection-1.15.0/lib/
convert:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/convert-3.0.0/lib/
crypto:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/crypto-3.0.1/lib/
dart_style:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/dart_style-2.0.1/lib/
file:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/file-6.1.1/lib/
fixnum:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/fixnum-1.0.0/lib/
frontend_server_client:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/frontend_server_client-2.1.0/lib/
get_it:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/get_it-7.1.3/lib/
glob:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/glob-2.0.1/lib/
graphs:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/graphs-2.0.0/lib/
http_multi_server:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/http_multi_server-3.0.1/lib/
http_parser:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/http_parser-4.0.0/lib/
injectable:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/injectable-1.4.1/lib/
injectable_generator:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/injectable_generator-1.4.1/lib/
io:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/io-1.0.0/lib/
js:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/js-0.6.3/lib/
json_annotation:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/json_annotation-4.0.1/lib/
logging:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/logging-1.0.1/lib/
matcher:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/matcher-0.12.10/lib/
meta:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/meta-1.3.0/lib/
mime:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/mime-1.0.0/lib/
package_config:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/package_config-2.0.0/lib/
path:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/path-1.8.0/lib/
pedantic:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/pedantic-1.11.0/lib/
pool:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/pool-1.5.0/lib/
pub_semver:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/pub_semver-2.0.0/lib/
pubspec_parse:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/pubspec_parse-1.0.0/lib/
shelf:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/shelf-1.1.4/lib/
shelf_web_socket:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/shelf_web_socket-1.0.1/lib/
smartstruct:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/smartstruct-1.2.2/lib/
smartstruct_generator:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/smartstruct_generator-1.2.2/lib/
source_gen:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/source_gen-1.0.1/lib/
source_span:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/source_span-1.8.1/lib/
stack_trace:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/stack_trace-1.10.0/lib/
stream_channel:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/stream_channel-2.1.0/lib/
stream_transform:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/stream_transform-2.0.0/lib/
string_scanner:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/string_scanner-1.1.0/lib/
term_glyph:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/term_glyph-1.2.0/lib/
timing:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/timing-1.0.0/lib/
typed_data:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/typed_data-1.3.0/lib/
watcher:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/watcher-1.0.0/lib/
web_socket_channel:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/web_socket_channel-2.1.0/lib/
yaml:file:///C:/Users/Nils/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/yaml-3.1.0/lib/
# Generated by pub on 2021-07-01 15:04:15.654774.
_fe_analyzer_shared:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/_fe_analyzer_shared-22.0.0/lib/
analyzer:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/analyzer-1.7.1/lib/
args:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/args-2.1.1/lib/
async:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/async-2.7.0/lib/
build:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/build-2.0.2/lib/
build_config:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/build_config-1.0.0/lib/
build_daemon:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/build_daemon-3.0.0/lib/
build_resolvers:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/build_resolvers-2.0.3/lib/
build_runner:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/build_runner-2.0.4/lib/
build_runner_core:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/build_runner_core-7.0.0/lib/
built_collection:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/built_collection-5.0.0/lib/
built_value:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/built_value-8.0.6/lib/
charcode:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/charcode-1.2.0/lib/
checked_yaml:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/checked_yaml-2.0.1/lib/
cli_util:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/cli_util-0.3.0/lib/
code_builder:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/code_builder-4.0.0/lib/
collection:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/collection-1.15.0/lib/
convert:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/convert-3.0.0/lib/
crypto:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/crypto-3.0.1/lib/
dart_style:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/dart_style-2.0.1/lib/
file:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/file-6.1.1/lib/
fixnum:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/fixnum-1.0.0/lib/
frontend_server_client:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/frontend_server_client-2.1.0/lib/
get_it:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/get_it-7.1.3/lib/
glob:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/glob-2.0.1/lib/
graphs:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/graphs-2.0.0/lib/
http_multi_server:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/http_multi_server-3.0.1/lib/
http_parser:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/http_parser-4.0.0/lib/
injectable:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/injectable-1.4.1/lib/
injectable_generator:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/injectable_generator-1.4.1/lib/
io:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/io-1.0.0/lib/
js:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/js-0.6.3/lib/
json_annotation:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/json_annotation-4.0.1/lib/
logging:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/logging-1.0.1/lib/
matcher:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.10/lib/
meta:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0/lib/
mime:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/mime-1.0.0/lib/
package_config:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/package_config-2.0.0/lib/
path:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/path-1.8.0/lib/
pedantic:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/pedantic-1.11.0/lib/
pool:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/pool-1.5.0/lib/
pub_semver:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/pub_semver-2.0.0/lib/
pubspec_parse:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/pubspec_parse-1.0.0/lib/
shelf:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/shelf-1.1.4/lib/
shelf_web_socket:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/shelf_web_socket-1.0.1/lib/
smartstruct:../smartstruct/lib/
smartstruct_generator:../generator/lib/
source_gen:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/source_gen-1.0.1/lib/
source_span:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/source_span-1.8.1/lib/
stack_trace:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.10.0/lib/
stream_channel:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.1.0/lib/
stream_transform:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/stream_transform-2.0.0/lib/
string_scanner:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.1.0/lib/
term_glyph:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.2.0/lib/
timing:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/timing-1.0.0/lib/
typed_data:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/typed_data-1.3.0/lib/
watcher:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/watcher-1.0.0/lib/
web_socket_channel:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/web_socket_channel-2.1.0/lib/
yaml:file:///Users/kamilmrowiec/.pub-cache/hosted/pub.dartlang.org/yaml-3.1.0/lib/
smartstruct_example:lib/
19 changes: 19 additions & 0 deletions example/lib/case_sensitive/case_sensitive.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'package:smartstruct/smartstruct.dart';
part 'case_sensitive.mapper.g.dart';

class Source {
final String userName;

Source(this.userName);
}

class Target {
final String username;

Target({required this.username});
}

@Mapper(caseSensitiveFields: false)
abstract class ExampleMapper {
Target fromSource(Source source);
}
17 changes: 17 additions & 0 deletions example/lib/case_sensitive/case_sensitive.mapper.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions example/lib/custom_mapping/custom_mapping.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import 'package:smartstruct/smartstruct.dart';

part 'custom_mapping.mapper.g.dart';

class Source {
final String firstName;
final String lastName;
final String birthDate;
final String avatar;

Source(
this.firstName,
this.lastName,
this.birthDate,
this.avatar,
);
}

class Target {
final String fullName;
final DateTime birthDate;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only constructor parameters are paid attention to by the generator.
If i change the Target class in the example custom_mapping.dart to the following.

class Target {
  final String fullName;
  DateTime? birthDate;
  final String avatar;

  Target(
    this.fullName,
    this.avatar,
  );
}

With the custom mapping of birthdate (not changed)

@Mapper()
abstract class CustomMapper {
  @DateTimeFromSourceMapper(targetField: "birthDate", f: mapBirthDate)
  @CustomMapping(targetField: "fullName", f: mapFullName)
  Target fromSource(Source source);
}

The birthDate is ignored by the generator.

final String avatar;

Target(
this.fullName,
this.birthDate,
this.avatar,
);
}

// To have type safety you need extend CustomMapping generic class with specific types.
class DateTimeFromSourceMapper extends CustomMapping<DateTime, Source> {
const DateTimeFromSourceMapper(
{required String targetField, required DateTime Function(Source) f})
: super(targetField: targetField, f: f);
}

// It is type safety way. It must be top level function.
DateTime mapBirthDate(Source input) => DateTime.parse(input.birthDate);

// This is not type safe way, but you don't need to override CustomMapping. It must be top level function.
dynamic mapFullName(dynamic input) {
final castedInput = input as Source;
return '${castedInput.firstName} ${castedInput.lastName}';
}

@Mapper()
abstract class CustomMapper {
@DateTimeFromSourceMapper(targetField: "birthDate", f: mapBirthDate)
@CustomMapping(targetField: "fullName", f: mapFullName)
Target fromSource(Source source);
}
18 changes: 18 additions & 0 deletions example/lib/custom_mapping/custom_mapping.mapper.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -317,19 +317,19 @@ packages:
source: hosted
version: "1.0.1"
smartstruct:
dependency: "direct main"
dependency: "direct dev"
description:
name: smartstruct
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.2"
path: "../smartstruct"
relative: true
source: path
version: "1.2.1"
smartstruct_generator:
dependency: "direct dev"
description:
name: smartstruct_generator
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.2"
path: "../generator"
relative: true
source: path
version: "1.2.1"
source_gen:
dependency: transitive
description:
Expand Down
6 changes: 3 additions & 3 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ dependencies:
dev_dependencies:
build_runner: ^2.0.4
injectable_generator: ^1.4.1
smartstruct_generator: ^1.2.2
# smartstruct_generator:
# path: ../generator
# smartstruct_generator: ^1.2.2
smartstruct_generator:
path: ../generator
13 changes: 13 additions & 0 deletions generator/lib/mapper_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,17 @@ class MapperConfig {
});
return config;
}

static Map<String, dynamic> readCustomMappingConfig(MethodElement method) {
final config = <String, dynamic>{};
final annotations =
TypeChecker.fromRuntime(CustomMapping).annotationsOf(method);

annotations.forEach((element) {
var reader = ConstantReader(element);
config[reader.read('targetField').stringValue] =
reader.read('f').objectValue;
});
return config;
}
}
Loading