You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "klcodanr (via GitHub)" <gi...@apache.org> on 2023/03/01 19:38:36 UTC
[GitHub] [sling-org-apache-sling-resourcecollection] klcodanr opened a new pull request, #3: SLING-11794 - Adding a new method to get the properties as an adapted type
klcodanr opened a new pull request, #3:
URL: https://github.com/apache/sling-org-apache-sling-resourcecollection/pull/3
Changes:
- Adds a new method to get the properties of an entry in the resource collection as a specified type
See: https://issues.apache.org/jira/browse/SLING-11794
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [sling-org-apache-sling-resourcecollection] sonarcloud[bot] commented on pull request #3: SLING-11794 - Adding a new method to get the properties as an adapted type
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3:
URL: https://github.com/apache/sling-org-apache-sling-resourcecollection/pull/3#issuecomment-1450750456
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3)
[](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&metric=new_coverage&view=list) [100.0% Coverage](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&metric=new_duplicated_lines_density&view=list)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [sling-org-apache-sling-resourcecollection] joerghoh commented on a diff in pull request #3: SLING-11794 - Adding a new method to get the properties as an adapted type
Posted by "joerghoh (via GitHub)" <gi...@apache.org>.
joerghoh commented on code in PR #3:
URL: https://github.com/apache/sling-org-apache-sling-resourcecollection/pull/3#discussion_r1126663245
##########
src/main/java/org/apache/sling/resource/collection/ResourceCollection.java:
##########
@@ -67,7 +68,16 @@ public interface ResourceCollection {
/**
* Returns additional properties for a particular resource in Collection entry.
*
- * @return properties of the Collection entry as <code>ModifiableValueMap</code>, returns null if entry found.
+ * @return properties of the Collection entry as the specified type, returns empty if no entry found or
+ * the entry cannot be adapted to the type
+ */
+ <T> Optional<T> getPropertiesAs(Resource resource, Class<T> type);
Review Comment:
I wonder if we need that level of "generic" at this point here at all.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [sling-org-apache-sling-resourcecollection] sonarcloud[bot] commented on pull request #3: SLING-11794 - Adding a new method to get the properties as an adapted type
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3:
URL: https://github.com/apache/sling-org-apache-sling-resourcecollection/pull/3#issuecomment-1456599097
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3)
[](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&metric=new_coverage&view=list) [100.0% Coverage](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-resourcecollection&pullRequest=3&metric=new_duplicated_lines_density&view=list)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [sling-org-apache-sling-resourcecollection] klcodanr commented on a diff in pull request #3: SLING-11794 - Adding a new method to get the properties as an adapted type
Posted by "klcodanr (via GitHub)" <gi...@apache.org>.
klcodanr commented on code in PR #3:
URL: https://github.com/apache/sling-org-apache-sling-resourcecollection/pull/3#discussion_r1126724006
##########
src/main/java/org/apache/sling/resource/collection/ResourceCollection.java:
##########
@@ -67,7 +68,16 @@ public interface ResourceCollection {
/**
* Returns additional properties for a particular resource in Collection entry.
*
- * @return properties of the Collection entry as <code>ModifiableValueMap</code>, returns null if entry found.
+ * @return properties of the Collection entry as the specified type, returns empty if no entry found or
+ * the entry cannot be adapted to the type
+ */
+ <T> Optional<T> getPropertiesAs(Resource resource, Class<T> type);
Review Comment:
Good point, especially in light of this class not functionally changing in a decade. I reverted to just returning the ValueMap and ensuring that the ValueMap will never be null (though it may be empty if the resource is not found in the collection or the adaption fails)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [sling-org-apache-sling-resourcecollection] joerghoh commented on a diff in pull request #3: SLING-11794 - Adding a new method to get the properties as an adapted type
Posted by "joerghoh (via GitHub)" <gi...@apache.org>.
joerghoh commented on code in PR #3:
URL: https://github.com/apache/sling-org-apache-sling-resourcecollection/pull/3#discussion_r1125500175
##########
src/main/java/org/apache/sling/resource/collection/ResourceCollection.java:
##########
@@ -67,7 +68,16 @@ public interface ResourceCollection {
/**
* Returns additional properties for a particular resource in Collection entry.
*
- * @return properties of the Collection entry as <code>ModifiableValueMap</code>, returns null if entry found.
+ * @return properties of the Collection entry as the specified type, returns empty if no entry found or
+ * the entry cannot be adapted to the type
+ */
+ <T> Optional<T> getPropertiesAs(Resource resource, Class<T> type);
Review Comment:
You can provide as type also a SlingModel class. Is this something we want to support?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [sling-org-apache-sling-resourcecollection] klcodanr merged pull request #3: SLING-11794 - Adding a new method to get the properties as an adapted type
Posted by "klcodanr (via GitHub)" <gi...@apache.org>.
klcodanr merged PR #3:
URL: https://github.com/apache/sling-org-apache-sling-resourcecollection/pull/3
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [sling-org-apache-sling-resourcecollection] klcodanr commented on pull request #3: SLING-11794 - Adding a new method to get the properties as an adapted type
Posted by "klcodanr (via GitHub)" <gi...@apache.org>.
klcodanr commented on PR #3:
URL: https://github.com/apache/sling-org-apache-sling-resourcecollection/pull/3#issuecomment-1454106314
Thanks @rombert, unfortunately, I'm not sure there are many / any who are overly familiar with the module. Looks like the last _real_ changes were in 2013 from @cziegeler
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [sling-org-apache-sling-resourcecollection] klcodanr commented on a diff in pull request #3: SLING-11794 - Adding a new method to get the properties as an adapted type
Posted by "klcodanr (via GitHub)" <gi...@apache.org>.
klcodanr commented on code in PR #3:
URL: https://github.com/apache/sling-org-apache-sling-resourcecollection/pull/3#discussion_r1126639515
##########
src/main/java/org/apache/sling/resource/collection/ResourceCollection.java:
##########
@@ -67,7 +68,16 @@ public interface ResourceCollection {
/**
* Returns additional properties for a particular resource in Collection entry.
*
- * @return properties of the Collection entry as <code>ModifiableValueMap</code>, returns null if entry found.
+ * @return properties of the Collection entry as the specified type, returns empty if no entry found or
+ * the entry cannot be adapted to the type
+ */
+ <T> Optional<T> getPropertiesAs(Resource resource, Class<T> type);
Review Comment:
@joerghoh yeah, I debated making it more specific (e.g. get the `ValueMap` or `Resource`) but decided allowing any adaptable target class would both make the code cleaner and be more generic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org