Details
-
Sub-task
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
-
mac 10.5.2 java.1.5 Groovy Version: 1.1-rc-2 JVM: 1.5.0_13-119
Description
class CP implements Comparable
{
int number
int compareTo(obj)
{ println 'compareTo called' return number - obj.number }boolean equals(obj)
{ println 'equals called' return obj.number = number }}
// script
def cp1 = new CP(number:1)
def cp2 = new CP(number:2)
cp1==cp2
// results
if CP implements Comparable, compareTo is called, if not, equals is called
// using grails with above as follows has ominous implications
I have a setup similar to as follows:
TopLevelDomainClass
SubLevelDomainClass implements Comparable
{
int number
int compareTo(obj)
}
sublevel1==sublevel2 calls the compareTo function for evaluation