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

Allow mapping input to public properties [updated]. #14

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ratiw
Copy link

@ratiw ratiw commented Jul 28, 2014

Sometimes when we have a DTO class which will contain a lot of properties (more than 5 or 6 properties), it does not do any good defining all those properties in the constructor.

This PR will allow mapping input to the "public properties" instead of using the constructor.

@stidges
Copy link

stidges commented Jul 30, 2014

I'd like to have this option as well (I ran into a case where I had 36 constructor parameters...).

One thing that I think you could improve is that it should be a little more strict to match the same behavior as if it were constructor parameters:

  • Throw an exception when attributes are passed through that don't exist as properties on the command.
  • Throw an exception when properties which are defined on the command are missing from the attributes.

What do you think?

@ratiw
Copy link
Author

ratiw commented Jul 31, 2014

@stidges Well, I think that can be done. I just initially thought it is unnecessary so the code I wrote only maps the inputs to the existing public properties only. I'll try to make it more strict and consistent with the original code. Thanks for the comment, anyway. :)

@ratiw
Copy link
Author

ratiw commented Jul 31, 2014

@stidges Now, the mapInputToCommandProperties() should throw an exception when any public property is not present in the input, so it behaves more like it constructor counterpart. By the way, any other input that is/are not defined in the command (DTO) will be ignored.

bruno-barros and others added 3 commits August 4, 2014 23:51
prevent throw exception if parameter has default value
prevent throw exception if has default value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants