remondis-it / remap

A declarative mapping library to simplify testable object mappings.
Apache License 2.0
122 stars 22 forks source link

Suggestion : omitAll #84

Closed mmaryo closed 5 years ago

mmaryo commented 5 years ago

Hello

Sometime I just need to map some fields and I do not matter for the others and new It's tedious to omit each field

For exemple I create a "little" object with 6 or 7 fields and need to copie them from an object with 30 or 40 fields -> by using ReMap, it's long and boring to write mapping

What do you think about omitAll() ?

schuettec commented 5 years ago

Hi, I understand this. I often think about providing a way to use ReMap in a less strict way - but I'm not sure how to integrate this in the API. I would like a way that you cannot accidentally mix the strict and the relaxed mapping mode.

schuettec commented 5 years ago

Okay the omitAll() method in the Mapper with a documented warning is okay I think. But adding this feature also for the Assert API doesn't seem to be right: expectOmitAll feels too unspecific and leaves enough space for erroneously excluding fields.

mmaryo commented 5 years ago

Mapping.from(Customer.class) .to(Person.class) .reassign(Customer::getTitle) .to(Person::getSalutation) .omitAllTheRest() .mapper();

By using omitAllTheRest() (or omitAll()), remap continue works normally, but just skip the all fields mapping check It's a decision from the developer

what do you think ?

schuettec commented 5 years ago

As I mentioned: The method Mapper.omitAll() is fine for me, but I have to think about the AssertMapping-part of the API as described above.

schuettec commented 5 years ago

FYI: https://github.com/remondis-it/remap/pull/85

mmaryo commented 5 years ago

I not sure I can help you for AssertMapping But, great PR ! I am looking forward to the release

schuettec commented 5 years ago

Cool.

I have an idea for the AssertMapping but I need a day to test it. If you have an idea your PR is welcome :)

I would suggest to do a release now so we get the feature early.

schuettec commented 5 years ago

Release 4.1.5 is on its way. I will open an issue for AssertMapping.expectOthersToBeOmitted().