|
From: Peter De B. (JIRA) <no...@at...> - 2007-11-29 08:31:16
|
[ http://opensource.atlassian.com/projects/spring/browse/RCP-394?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_28039 ]
Peter De Bruycker commented on RCP-394:
---------------------------------------
I've checked a NumberComparator in that can be used for this scenario:
use the method Constraints.range(Integer.valueOf(0), Integer.valueOf(10), NumberComparator.INSTANCE) to create the constraint.
then constraint.test(Double.valueOf(5.5) will return true.
> Number Constraints where not able to compare values which are numbers but not of the same type
> ----------------------------------------------------------------------------------------------
>
> Key: RCP-394
> URL: http://opensource.atlassian.com/projects/spring/browse/RCP-394
> Project: Spring Framework Rich Client Project
> Issue Type: Bug
> Components: Helper Classes
> Affects Versions: 0.1.0, 0.2.0
> Reporter: Mathias Broekelmann
> Assignee: Mathias Broekelmann
>
> consider a constraint as follows:
> Constraint constraint = new Range(0, 10);
> The expected behavior of the following test is to return true:
> constraint.test(new Double(5.5))
> but it fires a ClassCastException since Range wrapped the integers into their object types and the compareTo method of Integer casts its argument to Integer
> I have a use case with a JFormatedTextField which creates different number instances on different Inputs:
> input = 5 results in a Long instance
> input = 5.5 results in a Double instance
> This problem can be solved by a custom comparator but it is a pain for the user since he is not able to use the provided methods in Constraints class.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/spring/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|