struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject svn commit: r1428071 - /struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/AbstractRangeValidator.java
Date Wed, 02 Jan 2013 21:40:21 GMT
Author: lukaszlenart
Date: Wed Jan  2 21:40:21 2013
New Revision: 1428071

URL: http://svn.apache.org/viewvc?rev=1428071&view=rev
Log:
WW-2923 adds better support for generics

Modified:
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/AbstractRangeValidator.java

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/AbstractRangeValidator.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/AbstractRangeValidator.java?rev=1428071&r1=1428070&r2=1428071&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/AbstractRangeValidator.java
(original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/AbstractRangeValidator.java
Wed Jan  2 21:40:21 2013
@@ -15,6 +15,7 @@
  */
 package com.opensymphony.xwork2.validator.validators;
 
+import com.opensymphony.xwork2.util.TextParseUtil;
 import com.opensymphony.xwork2.validator.ValidationException;
 
 
@@ -26,6 +27,12 @@ import com.opensymphony.xwork2.validator
  */
 public abstract class AbstractRangeValidator<T extends Comparable> extends FieldValidatorSupport
{
 
+    private final Class<T> type;
+
+    protected AbstractRangeValidator(Class<T> type) {
+        this.type = type;
+    }
+
     public void validate(Object object) throws ValidationException {
         Object obj = getFieldValue(getFieldName(), object);
         Comparable<T> value = (Comparable<T>) obj;
@@ -49,16 +56,15 @@ public abstract class AbstractRangeValid
         }
     }
 
+    protected T parse(String expression) {
+        if (expression == null) {
+            return null;
+        }
+        return (T) TextParseUtil.translateVariables('$', expression, stack, type);
+    }
+
     protected abstract T getMaxComparatorValue();
 
     protected abstract T getMinComparatorValue();
 
-    protected String safeConditionalParse(String expression) {
-        Object value = conditionalParse(expression);
-        if (value != null) {
-            return value.toString();
-        } else {
-            return null;
-        }
-    }
 }



Mime
View raw message