Revision: 1771
          http://svn.sourceforge.net/spring-rich-c/?rev=1771&view=rev
Author:   jhoskens
Date:     2007-07-06 01:41:13 -0700 (Fri, 06 Jul 2007)

Log Message:
-----------
Added typeresolvable support for ConditionalPropertyConstraint

Modified Paths:
--------------
    
trunk/spring-richclient/support/src/main/java/org/springframework/rules/constraint/property/ConditionalPropertyConstraint.java
    
trunk/spring-richclient/support/src/main/java/org/springframework/rules/factory/Constraints.java

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/rules/constraint/property/ConditionalPropertyConstraint.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/rules/constraint/property/ConditionalPropertyConstraint.java
      2007-07-05 13:42:11 UTC (rev 1770)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/rules/constraint/property/ConditionalPropertyConstraint.java
      2007-07-06 08:41:13 UTC (rev 1771)
@@ -2,6 +2,7 @@
 
 import org.springframework.binding.PropertyAccessStrategy;
 import org.springframework.rules.constraint.IfTrue;
+import org.springframework.rules.reporting.TypeResolvable;
 import org.springframework.util.Assert;
 
 /**
@@ -51,7 +52,7 @@
  * @author jh
  * 
  */
-public class ConditionalPropertyConstraint extends AbstractPropertyConstraint {
+public class ConditionalPropertyConstraint extends AbstractPropertyConstraint 
implements TypeResolvable {
 
        /** The condition which triggers further rules to be checked. */
        private final PropertyConstraint ifConstraint;
@@ -62,7 +63,17 @@
        /** The constraint to be checked when the condition is <b>NOT</b> 
satisfied. */
        private final PropertyConstraint elseConstraint;
 
+       /** Type used to fetch message. */
+       private String type;
+
        /**
+        * @see #ConditionalPropertyConstraint(PropertyConstraint, 
PropertyConstraint, String)
+        */
+       public ConditionalPropertyConstraint(PropertyConstraint ifConstraint, 
PropertyConstraint thenConstraint) {
+               this(ifConstraint, thenConstraint, null, null);
+       }       
+       
+       /**
         * Create a constraint which simulates the if...then pattern applied
         * on separate properties.
         * 
@@ -71,11 +82,18 @@
         * @param thenConstraint the PropertyConstraint to test in the specified
         * condition.
         */
-       public ConditionalPropertyConstraint(PropertyConstraint ifConstraint, 
PropertyConstraint thenConstraint) {
-               this(ifConstraint, thenConstraint, null);
+       public ConditionalPropertyConstraint(PropertyConstraint ifConstraint, 
PropertyConstraint thenConstraint, String type) {
+               this(ifConstraint, thenConstraint, null, type);
        }
        
        /**
+        * @see #ConditionalPropertyConstraint(PropertyConstraint, 
PropertyConstraint, PropertyConstraint, String)
+        */
+       public ConditionalPropertyConstraint(PropertyConstraint ifConstraint, 
PropertyConstraint thenConstraint,
+                       PropertyConstraint elseConstraint) {
+               this(ifConstraint, thenConstraint, elseConstraint, null);
+       }
+       /**
         * Create a constraint which simulates the if...then...else pattern 
applied
         * on separate properties.
         * 
@@ -85,15 +103,17 @@
         * condition.
         * @param elseConstraint the PropertyConstraint to test if the 
condition is
         * <b>NOT</b> satisfied. May be <code>null</code>.
+        * @param type the messageCode used to fetch the message.
         */
        public ConditionalPropertyConstraint(PropertyConstraint ifConstraint, 
PropertyConstraint thenConstraint,
-                       PropertyConstraint elseConstraint) {
+                       PropertyConstraint elseConstraint, String type) {
                super(ifConstraint.getPropertyName());
                Assert.notNull(ifConstraint);
                Assert.notNull(thenConstraint);
                this.ifConstraint = ifConstraint;
                this.thenConstraint = thenConstraint;
                this.elseConstraint = elseConstraint;
+               this.type = type;
        }
 
        public boolean isCompoundRule() {
@@ -117,4 +137,11 @@
                return true;
        }
 
+       public String getType() {
+               return type;
+       }
+
+       public void setType(String type) {
+               this.type = type;
+       }
 }

Modified: 
trunk/spring-richclient/support/src/main/java/org/springframework/rules/factory/Constraints.java
===================================================================
--- 
trunk/spring-richclient/support/src/main/java/org/springframework/rules/factory/Constraints.java
    2007-07-05 13:42:11 UTC (rev 1770)
+++ 
trunk/spring-richclient/support/src/main/java/org/springframework/rules/factory/Constraints.java
    2007-07-06 08:41:13 UTC (rev 1771)
@@ -331,6 +331,16 @@
                return new ConditionalPropertyConstraint(ifConstraint, 
thenConstraint);
        }
     
+       /**
+        * Returns a ConditionalPropertyConstraint: one property will trigger 
the
+        * validation of another.
+        * 
+        * @see ConditionalPropertyConstraint
+        */
+       public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, 
PropertyConstraint thenConstraint, String type) {
+               return new ConditionalPropertyConstraint(ifConstraint, 
thenConstraint, type);
+       }
+       
     /**
         * Returns a ConditionalPropertyConstraint: one property will trigger 
the
         * validation of another.
@@ -348,9 +358,30 @@
         * 
         * @see ConditionalPropertyConstraint
         */
+       public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, 
PropertyConstraint thenConstraint,
+                       PropertyConstraint elseConstraint, String type) {
+               return new ConditionalPropertyConstraint(ifConstraint, 
thenConstraint, elseConstraint, type);
+       }
+       
+       /**
+        * Returns a ConditionalPropertyConstraint: one property will trigger 
the
+        * validation of another.
+        * 
+        * @see ConditionalPropertyConstraint
+        */
        public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, 
PropertyConstraint[] thenConstraints) {
                return new ConditionalPropertyConstraint(ifConstraint, new 
CompoundPropertyConstraint(new And(thenConstraints)));
        }
+       
+       /**
+        * Returns a ConditionalPropertyConstraint: one property will trigger 
the
+        * validation of another.
+        * 
+        * @see ConditionalPropertyConstraint
+        */
+       public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, 
PropertyConstraint[] thenConstraints, String type) {
+               return new ConditionalPropertyConstraint(ifConstraint, new 
CompoundPropertyConstraint(new And(thenConstraints)), type);
+       }
     
     /**
         * Returns a ConditionalPropertyConstraint: one property will trigger 
the
@@ -364,6 +395,19 @@
                                new CompoundPropertyConstraint(new 
And(thenConstraints)), new CompoundPropertyConstraint(new And(
                                                elseConstraints)));
        }
+       
+       /**
+        * Returns a ConditionalPropertyConstraint: one property will trigger 
the
+        * validation of another.
+        * 
+        * @see ConditionalPropertyConstraint
+        */
+       public PropertyConstraint ifTrue(PropertyConstraint ifConstraint, 
PropertyConstraint[] thenConstraints,
+                       PropertyConstraint[] elseConstraints, String type) {
+               return new ConditionalPropertyConstraint(ifConstraint,
+                               new CompoundPropertyConstraint(new 
And(thenConstraints)), new CompoundPropertyConstraint(new And(
+                                               elseConstraints)), type);
+       }
 
     /**
         * Returns a maxlength constraint.


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
spring-rich-c-cvs mailing list
spring-rich-c-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spring-rich-c-cvs

Reply via email to