Author: apetrelli
Date: Sat Mar 20 12:43:40 2010
New Revision: 925590

URL: http://svn.apache.org/viewvc?rev=925590&view=rev
Log:
TILESSB-29
Added new method VelocityUtil.getObject.

Modified:
    
tiles/sandbox/trunk/tiles3/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/VelocityUtil.java

Modified: 
tiles/sandbox/trunk/tiles3/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/VelocityUtil.java
URL: 
http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles3/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/VelocityUtil.java?rev=925590&r1=925589&r2=925590&view=diff
==============================================================================
--- 
tiles/sandbox/trunk/tiles3/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/VelocityUtil.java
 (original)
+++ 
tiles/sandbox/trunk/tiles3/tiles-velocity/src/main/java/org/apache/tiles/velocity/context/VelocityUtil.java
 Sat Mar 20 12:43:40 2010
@@ -170,4 +170,20 @@ public final class VelocityUtil {
                 .value(context);
         return params;
     }
+
+    /**
+     * Returns the "value" parameter if it is not null, otherwise returns
+     * "defaultValue".
+     *
+     * @param value The value to return, if it is not null.
+     * @param defaultValue The value to return, if <code>value</code> is null.
+     * @return The value, defaulted if necessary.
+     * @since 3.0.0
+     */
+    public static Object getObject(Object value, Object defaultValue) {
+        if (value == null) {
+            value = defaultValue;
+        }
+        return value;
+    }
 }


Reply via email to