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

Need more types of conversions supported #642

Closed
yuanpli opened this issue Jun 5, 2018 · 5 comments
Closed

Need more types of conversions supported #642

yuanpli opened this issue Jun 5, 2018 · 5 comments

Comments

@yuanpli
Copy link
Contributor

yuanpli commented Jun 5, 2018

Hi,

Can the dozer provide more types of conversions by default?

Such as:

  • String to Enum
  • String to Boolean
  • Integer to Boolean
  • Nested Map key Mapping
    etc.

For Nested Map key Mapping, it is imaged like:

    <mapping>
        <class-a>java.util.Map</class-a>
        <class-b>org.dozer.vo.example.ClassA</class-b>
        <field>
            <a key="key1">this</a>
            <b>nestedMap["key2"]</b>
        </field>
    </mapping>

Thanks a lot!

Br,
Yuanping

@garethahealy
Copy link
Collaborator

@yuanpli ; if you are willing to create PRs, i am willing to review/merge.

@yuanpli
Copy link
Contributor Author

yuanpli commented Jun 6, 2018

Hi,

I find that the basic String To Enum is supported already. But the String in Map is not as below testcase.

public void canStringInMapMapsToEnum() {
        Map src = newInstance(HashMap.class);
        src.put("destType", "FOO");

        MyBeanPrime dest = enumMappingOverriedEnumToBasedEnum.map(src, MyBeanPrime.class);
        assertEquals("FOO", dest.getDestType().toString());
    }

I have created the PR for this change, could you kindly review it? Thanks a lot!

yuanpli added a commit to yuanpli/dozer that referenced this issue Jun 6, 2018
garethahealy pushed a commit that referenced this issue Jun 11, 2018
* #642 Support the conversion of String In Map To Enum

*  #642 Support the conversion of String In Map To Enum

* Refactor after code review

* Update according to the comments of review
@yuanpli
Copy link
Contributor Author

yuanpli commented Jun 12, 2018

I find that the nested map conversion is supported via the following configuration.

    <mapping wildcard="true">
        <class-a>java.util.HashMap</class-a>
        <class-b>com.github.dozermapper.core.vo.map.SimpleObj</class-b>
        <field>
            <a key="key1">this</a>
            <b key="key2">nested2</b>
        </field>
    </mapping>

That is great and easy to understand.

@garethahealy
Copy link
Collaborator

@yuanpli ; are all conversions covered? can this be closed?

@yuanpli
Copy link
Contributor Author

yuanpli commented Jun 14, 2018

Hi @garethahealy, it seems that String/Integer to Boolean and reverse conversions are not covered by default after checked from the UT com.github.dozermapper.core.functional_tests.NewCustomConverterTest.

From my point of view, it would be better if can make these conversions be built-in functionalities since those are so common to use, and also belongs to the primitive type conversion.

If there is no plan at this momont, this ticket can be closed.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants