struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject svn commit: r1428293 - /struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/
Date Thu, 03 Jan 2013 11:29:38 GMT
Author: lukaszlenart
Date: Thu Jan  3 11:29:38 2013
New Revision: 1428293

URL: http://svn.apache.org/viewvc?rev=1428293&view=rev
Log:
Removes duplicated code

Modified:
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/AbstractRangeValidator.java
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/DateRangeFieldValidator.java
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/IntRangeFieldValidator.java
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/LongRangeFieldValidator.java
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/ShortRangeFieldValidator.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=1428293&r1=1428292&r2=1428293&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
Thu Jan  3 11:29:38 2013
@@ -15,7 +15,6 @@
  */
 package com.opensymphony.xwork2.validator.validators;
 
-import com.opensymphony.xwork2.util.TextParseUtil;
 import com.opensymphony.xwork2.validator.ValidationException;
 
 
@@ -27,7 +26,13 @@ import com.opensymphony.xwork2.validator
  */
 public abstract class AbstractRangeValidator<T extends Comparable> extends FieldValidatorSupport
{
 
-    private final Class<T> type;
+    protected final Class<T> type;
+
+    private T min;
+    private T max;
+
+    private String minExpression;
+    private String maxExpression;
 
     protected AbstractRangeValidator(Class<T> type) {
         this.type = type;
@@ -56,15 +61,50 @@ public abstract class AbstractRangeValid
         }
     }
 
-    protected T parse(String expression) {
-        if (expression == null) {
-            return null;
+    public T getMinComparatorValue() {
+        if (parse) {
+            return (T) parse(getMinExpression(), type);
         }
-        return (T) TextParseUtil.translateVariables('$', expression, stack, type);
+        return getMin();
+    }
+
+    public void setMin(T min) {
+        this.min = min;
+    }
+
+    public T getMin() {
+        return min;
     }
 
-    protected abstract T getMaxComparatorValue();
+    public String getMinExpression() {
+        return minExpression;
+    }
 
-    protected abstract T getMinComparatorValue();
+    public void setMinExpression(String minExpression) {
+        this.minExpression = minExpression;
+    }
+
+    public void setMax(T max) {
+        this.max = max;
+    }
+
+    public T getMax() {
+        return max;
+    }
+
+    public String getMaxExpression() {
+        return maxExpression;
+    }
+
+    public void setMaxExpression(String maxExpression) {
+        this.maxExpression = maxExpression;
+    }
+
+    public T getMaxComparatorValue() {
+        if (parse) {
+            return (T) parse(getMaxExpression(), type);
+        }
+        return getMax();
+    }
 
 }

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/DateRangeFieldValidator.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/DateRangeFieldValidator.java?rev=1428293&r1=1428292&r2=1428293&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/DateRangeFieldValidator.java
(original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/DateRangeFieldValidator.java
Thu Jan  3 11:29:38 2013
@@ -88,61 +88,8 @@ import java.util.Date;
  */
 public class DateRangeFieldValidator extends AbstractRangeValidator<Date> {
 
-    private Date min;
-    private Date max;
-    private String minExpression;
-    private String maxExpression;
-
     public DateRangeFieldValidator() {
         super(Date.class);
     }
 
-    public void setMin(Date min) {
-        this.min = min;
-    }
-
-    public Date getMin() {
-        return min;
-    }
-
-    public String getMinExpression() {
-        return minExpression;
-    }
-
-    public void setMinExpression(String minExpression) {
-        this.minExpression = minExpression;
-    }
-
-    @Override
-    public Date getMinComparatorValue() {
-        if (parse) {
-            return parse(getMinExpression());
-        }
-        return getMin();
-    }
-
-    public void setMax(Date max) {
-        this.max = max;
-    }
-
-    public Date getMax() {
-        return max;
-    }
-
-    public String getMaxExpression() {
-        return maxExpression;
-    }
-
-    public void setMaxExpression(String maxExpression) {
-        this.maxExpression = maxExpression;
-    }
-
-    @Override
-    public Date getMaxComparatorValue() {
-        if (parse) {
-            return parse(getMaxExpression());
-        }
-        return getMax();
-    }
-
 }

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/IntRangeFieldValidator.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/IntRangeFieldValidator.java?rev=1428293&r1=1428292&r2=1428293&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/IntRangeFieldValidator.java
(original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/IntRangeFieldValidator.java
Thu Jan  3 11:29:38 2013
@@ -76,61 +76,8 @@ package com.opensymphony.xwork2.validato
  */
 public class IntRangeFieldValidator extends AbstractRangeValidator<Integer> {
 
-    private Integer min = null;
-    private Integer max = null;
-    private String minExpression;
-    private String maxExpression;
-
     public IntRangeFieldValidator() {
         super(Integer.class);
     }
 
-    public void setMin(Integer min) {
-        this.min = min;
-    }
-
-    public Integer getMin() {
-        return min;
-    }
-
-    public String getMinExpression() {
-        return minExpression;
-    }
-
-    public void setMinExpression(String minExpression) {
-        this.minExpression = minExpression;
-    }
-
-    @Override
-    public Integer getMinComparatorValue() {
-        if (parse) {
-            return parse(getMinExpression());
-        }
-        return getMin();
-    }
-
-    public void setMax(Integer max) {
-        this.max = max;
-    }
-
-    public Integer getMax() {
-        return max;
-    }
-
-    public String getMaxExpression() {
-        return maxExpression;
-    }
-
-    public void setMaxExpression(String maxExpression) {
-        this.maxExpression = maxExpression;
-    }
-
-    @Override
-    public Integer getMaxComparatorValue() {
-        if (parse) {
-            return parse(getMaxExpression());
-        }
-        return getMax();
-    }
-
 }

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/LongRangeFieldValidator.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/LongRangeFieldValidator.java?rev=1428293&r1=1428292&r2=1428293&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/LongRangeFieldValidator.java
(original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/LongRangeFieldValidator.java
Thu Jan  3 11:29:38 2013
@@ -75,61 +75,8 @@ package com.opensymphony.xwork2.validato
  */
 public class LongRangeFieldValidator extends AbstractRangeValidator<Long> {
 
-    private Long min;
-    private Long max;
-    private String minExpression;
-    private String maxExpression;
-
     public LongRangeFieldValidator() {
         super(Long.class);
     }
 
-    public void setMin(Long min) {
-        this.min = min;
-    }
-
-    public Long getMin() {
-        return min;
-    }
-
-    public String getMinExpression() {
-        return minExpression;
-    }
-
-    public void setMinExpression(String minExpression) {
-        this.minExpression = minExpression;
-    }
-
-    @Override
-    public Long getMinComparatorValue() {
-        if (parse) {
-            return parse(getMinExpression());
-        }
-        return getMin();
-    }
-
-    public void setMax(Long max) {
-        this.max = max;
-    }
-
-    public Long getMax() {
-        return max;
-    }
-
-    public String getMaxExpression() {
-        return maxExpression;
-    }
-
-    public void setMaxExpression(String maxExpression) {
-        this.maxExpression = maxExpression;
-    }
-
-    @Override
-    public Long getMaxComparatorValue() {
-        if (parse) {
-            return parse(getMaxExpression());
-        }
-        return getMax();
-    }
-
 }

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/ShortRangeFieldValidator.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/ShortRangeFieldValidator.java?rev=1428293&r1=1428292&r2=1428293&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/ShortRangeFieldValidator.java
(original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/validators/ShortRangeFieldValidator.java
Thu Jan  3 11:29:38 2013
@@ -74,61 +74,8 @@ package com.opensymphony.xwork2.validato
  */
 public class ShortRangeFieldValidator extends AbstractRangeValidator<Short> {
 
-    private Short min;
-    private Short max;
-    private String minExpression;
-    private String maxExpression;
-
     public ShortRangeFieldValidator() {
         super(Short.class);
     }
 
-    public void setMin(Short min) {
-        this.min = min;
-    }
-
-    public Short getMin() {
-        return min;
-    }
-
-    public String getMinExpression() {
-        return minExpression;
-    }
-
-    public void setMinExpression(String minExpression) {
-        this.minExpression = minExpression;
-    }
-
-    @Override
-    public Short getMinComparatorValue() {
-        if (parse) {
-            return parse(getMinExpression());
-        }
-        return getMin();
-    }
-
-    public void setMax(Short max) {
-        this.max = max;
-    }
-
-    public Short getMax() {
-        return max;
-    }
-
-    public String getMaxExpression() {
-        return maxExpression;
-    }
-
-    public void setMaxExpression(String maxExpression) {
-        this.maxExpression = maxExpression;
-    }
-
-    @Override
-    public Short getMaxComparatorValue() {
-        if (parse) {
-            return parse(getMaxExpression());
-        }
-        return getMax();
-    }
-
 }



Mime
View raw message