-
Notifications
You must be signed in to change notification settings - Fork 481
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
Mapping immutable types #216 #218
Conversation
@piotrdytkowski ; can you rebase with latest to force travis to retest |
@piotrdytkowski ; any update? |
Hey, sure, will have a look later. I don't like the name 'omit-constructor' anymore though... |
@piotrdytkowski ; have you had anytime to progress? |
Hey, I rebased the project, but now have a test failing (VariablesTest) in maven but passing in my IDE, must be something with deps or environment. I hope to sort it out soon. |
Now I see that master branch CI is failing for the same reason. I will update when you fix/revert master. |
@piotrdytkowski ; master branch has now been fixed. Can you rebase. |
I rebased but got some osgi tests failing, they seem unrelated but I can be wrong. Can you help me with this?
|
Hey @garethahealy , did you have any time to look at this? |
@piotrdytkowski ; no sorry, am currently on holiday, so might be a few weeks. |
core/pom.xml
Outdated
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
<version>4.12</version> | ||
</dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
junit isnt required. It comes from the parent pom, as per:
core/pom.xml
Outdated
<groupId>org.apache.maven.surefire</groupId> | ||
<artifactId>surefire-junit4</artifactId> | ||
<version>2.20</version> | ||
</dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What uses this dep? Cant see why its needed.
schema/pom.xml
Outdated
<groupId>org.apache.maven.surefire</groupId> | ||
<artifactId>surefire-junit4</artifactId> | ||
<version>2.20</version> | ||
</dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as other comment. Why are these 2 needed?
@piotrdytkowski ; the OSGi test are failing as you've added a new dependancy: org.objenesis. It needs to be added as a required dependancy in the OSGi tests: |
26a9613
to
9b70802
Compare
dozer-osgi-tests has a dependency on dozer-core so it should pull objenesis just fine. I rebased again and removed test libs added before. Hope to merge it soon 🍾 |
Like i said, you need to add the new dep to the OSGi container. Since my last comment, this has slightly changed, but if you look at: You'll see all the core deps needed. Those "link" URLS come from build time in:
|
Great, that's what I needed. Thanks :) |
c18794b
to
9b70802
Compare
5a55c67
to
88f07bd
Compare
Build is green. |
Hi! I think it is great functionality, but I cannot find a way to configure skipConstructor without XML, that is only with API. Is that possible with current code or (if not) maybe it should be a different PR? BR |
I didn't have a look at the api, back in 2014 when I implemented it maybe api configuration didn't even exist :D |
core/pom.xml
Outdated
<dependency> | ||
<groupId>org.objenesis</groupId> | ||
<artifactId>objenesis</artifactId> | ||
<version>2.6</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add this to the dependancyManagement section of the bom
Looks fine from my point of view. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@piotrdytkowski It would be great to extend the documentation (see docs/asciidoc/documentation
) with new feature description and example.
@garethahealy with objenesis
dependency added, Dozer now pulls quite some list of dependencies into user's projects. Probably we should think about improvement here. Maybe creating one single uber jar with shaded dependencies could be an option..
return skipConstructor != null && skipConstructor; | ||
} | ||
|
||
public void setSkipConstructor(Boolean omitConstructor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to rename the method parameter to match the property name.
@@ -511,6 +511,10 @@ public void mapEmptyString(Boolean value) { | |||
public void isAccessible(Boolean value) { | |||
definition.setAccessible(value); | |||
} | |||
|
|||
public void isSkipConstructor(Boolean skipConstructor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend to rename this method to skipConstructor
as it reflects the underlying configuration option more accurately.
} | ||
|
||
private <T> T newInstance(Class<T> clazz) { | ||
ObjectInstantiator<T> instantiator = objectFactory.getInstantiatorOf(clazz); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we are not loosing the semantics here. According to the javadocs, org.objenesis.Objenesis#getInstantiatorOf
:
Will pick the best instantiator for the provided class
Which includes constructor instantiator if constructor is provided for the target class.
As we rely on parameter skip-constructor
, users would expect that their constructors will never be invoked. Thus it makes sense to use org.objenesis.Objenesis#newInstance
, as it:
Will create a new object without any constructor being called
# Conflicts: # bom-dependencies/pom.xml
Review the changes, please. I had to make that last commit to retrigger the build, because it ... randomly failed. Thanks for the feedback, good spot with the ObjectInstantiator. Thanks 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@piotrdytkowski Thanks for the update!
Looks good to me.
Allows to use no-args constructor to create immutable objects