[ http://jira.andromda.org/browse/OCL-18?page=comments#action_12358 ]
     
Chad Brandon commented on OCL-18:
---------------------------------

Thanks for the patch, Justin.  Would you mind creating a patch file and 
attaching that? (would make it much easier for me to apply).

> Patch to add some more overloads to OCLExpressions
> --------------------------------------------------
>
>          Key: OCL-18
>          URL: http://jira.andromda.org/browse/OCL-18
>      Project: OCL Translation
>         Type: Improvement
>   Components: AndroMDA Validation
>     Versions: 3.1M1
>     Reporter: Justin Haddad
>     Assignee: Chad Brandon
>     Priority: Minor

>
> Below is a patch that adds a few overloads of less/greater/etc. methods.  
> These result from some initial testing that I did with adding OCL constraints 
> on entities and having the constraints be generated by the 
> HibernateEntity.vsl template.  These resolved some compilation errors, as 
> well as runtime ClassCastException (e.g. Long being passed into 
> Integer.compareTo).
> --------------------------------------------------------
> diff -ru 
> --- 
> .../andromda-src-3.1-M1/translation-libraries/ocl/andromda-validation/src/java/org/andromda/translation/ocl/validation/OCLExpressions.java
>         2005-08-12 13:05:47.000000000 -0400
> +++ 
> .../andromda-src-3.1-patched/translation-libraries/ocl/andromda-validation/src/java/org/andromda/translation/ocl/validation/OCLExpressions.java
>        2005-11-28 11:52:35.000000000 -0500
> @@ -135,6 +135,37 @@
>          return (first == null) ? (second == null) : (first.compareTo(second) 
> < 0);
>      }
> +    public static boolean less(Object first, Object second)
> +    {
> +        boolean less = first != null && 
> Comparable.class.isAssignableFrom(first.getClass());
> +        if(less) {
> +            less = ((Comparable)first).compareTo(second) < 0;
> +        }
> +        return less;
> +    }
> +
> +    public static boolean less(Object first, long second)
> +    {
> +        boolean less = first != null && 
> Comparable.class.isAssignableFrom(first.getClass());
> +        if (less)
> +        {
> +            Comparable comparable = (Comparable)first;
> +            less = comparable.compareTo(new Long(second)) < 0;
> +        }
> +        return less;
> +    }
> +
> +    public static boolean less(Object first, int second)
> +    {
> +        boolean less = first != null && 
> Comparable.class.isAssignableFrom(first.getClass());
> +        if (less)
> +        {
> +            Comparable comparable = (Comparable)first;
> +            less = comparable.compareTo(new Integer(second)) < 0;
> +        }
> +        return less;
> +    }
> +
>      public static boolean less(int first, int second)
>      {
>          return first < second;
> @@ -175,6 +206,15 @@
>          return (first == null) ? (second == null) : (first.compareTo(second) 
> <= 0);
>      }
> +    public static boolean lessOrEqual(Object first, Object second)
> +    {
> +        boolean less = first != null && 
> Comparable.class.isAssignableFrom(first.getClass());
> +        if(less) {
> +            less = ((Comparable)first).compareTo(second) <= 0;
> +        }
> +        return less;
> +    }
> +
>      public static boolean lessOrEqual(int first, int second)
>      {
>          return first <= second;
> @@ -215,6 +255,26 @@
>          return (first == null) ? (second == null) : (first.compareTo(second) 
> > 0);
>      }
> +    public static boolean greater(Object first, Object second)
> +    {
> +        boolean greater = first != null && 
> Comparable.class.isAssignableFrom(first.getClass());
> +        if(greater) {
> +            greater = ((Comparable)first).compareTo(second) > 0;
> +        }
> +        return greater;
> +    }
> +
> +    public static boolean greater(Object first, int second)
> +    {
> +        boolean greater = first != null && 
> Comparable.class.isAssignableFrom(first.getClass());
> +        if (greater)
> +        {
> +            Comparable comparable = (Comparable)first;
> +            greater = comparable.compareTo(new Integer(second)) > 0;
> +        }
> +        return greater;
> +    }
> +
>      public static boolean greater(Object first, long second)
>      {
>          boolean greater = first != null && 
> Comparable.class.isAssignableFrom(first.getClass());
> @@ -266,11 +326,31 @@
>          return (first == null) ? (second == null) : (first.compareTo(second) 
> >= 0);
>      }
> +    public static boolean greaterOrEqual(Object first, Object second)
> +    {
> +        boolean greater = first != null && 
> Comparable.class.isAssignableFrom(first.getClass());
> +        if(greater) {
> +            greater = ((Comparable)first).compareTo(second) >= 0;
> +        }
> +        return greater;
> +    }
> +
>      public static boolean greaterOrEqual(int first, int second)
>      {
>          return first >= second;
>      }
> +    public static boolean greaterOrEqual(Object first, long second)
> +    {
> +        boolean greater = first != null && 
> Comparable.class.isAssignableFrom(first.getClass());
> +        if (greater)
> +        {
> +            Comparable comparable = (Comparable)first;
> +            greater = comparable.compareTo(new Long(second)) >= 0;
> +        }
> +        return greater;
> +    }
> +
>      public static boolean greaterOrEqual(short first, short second)
>      {
>          return first >= second;




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click

Reply via email to