incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r705538 - /incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
Date Fri, 17 Oct 2008 09:54:04 GMT
Author: cziegeler
Date: Fri Oct 17 02:54:00 2008
New Revision: 705538

URL: http://svn.apache.org/viewvc?rev=705538&view=rev
Log:
Return empty map even if resource is null (avoids extra null checks)

Modified:
    incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java

Modified: incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java?rev=705538&r1=705537&r2=705538&view=diff
==============================================================================
--- incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
(original)
+++ incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/ResourceUtil.java
Fri Oct 17 02:54:00 2008
@@ -275,11 +275,13 @@
      * {@link ValueMap} class as an argument. If the <code>adaptTo</code>
      * method returns a map, this map is returned. If the resource is not
      * adaptable to a value map, an empty value map is returned.
+     * If <code>null</code> is provided as the resource an empty map is
+     * returned as well.
      * @param res The <code>Resource</code> to adapt to the value map.
      * @return A value map.
      */
     public static ValueMap getValueMap(final Resource res) {
-        ValueMap map = res.adaptTo(ValueMap.class);
+        ValueMap map = (res == null ? null : res.adaptTo(ValueMap.class));
         if ( map == null ) {
             map = ValueMap.EMPTY;
         }



Mime
View raw message