bkkothari2255 commented on code in PR #86:
URL:
https://github.com/apache/sling-org-apache-sling-models-impl/pull/86#discussion_r3035934118
##########
src/main/java/org/apache/sling/models/impl/AdapterImplementations.java:
##########
@@ -314,39 +316,71 @@ public Class<?> getModelClassForResource(final Resource
resource) {
return getModelClassForResource(resource,
resourceTypeMappingsForResources);
}
+ @SuppressWarnings("unchecked")
+ private static Map<Map<String, Class<?>>, Map<String, Object>>
getModelClassCache(final ResourceResolver resolver) {
+ return (Map<Map<String, Class<?>>, Map<String, Object>>)
+ resolver.getPropertyMap().get(CACHE_KEY);
+ }
+
protected static Class<?> getModelClassForResource(final Resource
resource, final Map<String, Class<?>> map) {
if (resource == null) {
return null;
}
ResourceResolver resolver = resource.getResourceResolver();
final String originalResourceType = resource.getResourceType();
+ if (originalResourceType.isEmpty()) {
+ return null;
+ }
+
+ Map<Map<String, Class<?>>, Map<String, Object>> cache =
getModelClassCache(resolver);
Review Comment:
Agreed! I'll encapsulate that structure into an inner class to make it much
easier to reason about, and push the change shortly
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]