-
Notifications
You must be signed in to change notification settings - Fork 30
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
SlingModelPersist type handling cleanup #73
base: master
Are you sure you want to change the base?
Conversation
@@ -18,10 +18,10 @@ | |||
*/ | |||
package org.apache.sling.models.persistor; | |||
|
|||
import com.drew.lang.annotations.NotNull; |
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.
@badvision any particular reason for changing annotation types? A number of other projects use the Jetbrains annotations, so it'd be better to be consistent
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.
Hmm good point, I think that was an oversight as I was having difficulty building in this one case -- happy to revert them back.
@@ -18,6 +18,7 @@ | |||
*/ | |||
package org.apache.sling.models.persistor.impl; | |||
|
|||
import com.drew.lang.annotations.NotNull; |
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 comment re:annotation
private static String getNodeType(Object obj) throws IllegalArgumentException, IllegalAccessException { | ||
for (Field f : obj.getClass().getDeclaredFields()) { | ||
Named namedAnnotation = f.getAnnotation(Named.class); | ||
if (namedAnnotation != null && namedAnnotation.value().equals("jcr:primaryType")) { |
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.
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.
agree, I try to avoid hard-coding too. Thanks for catching that.
SonarCloud Quality Gate failed. |
SonarCloud Quality Gate failed.
|
This cleans up how primary type and resource type are managed. I removed the child content type feature because it was too confusing to use and even more confusing in the code implementation. Now if you want a jcr:content child, add a content property to your object and use a @nAmed("jcr:content") annotation. This means that the java object graph should be more or less identical to the jcr node graph.