Details

    • Sub-task
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • groovy-runtime
    • 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

      { SortedSet subLevels static hasMany= [subLevels:SubLevelDomainClass] }

      SubLevelDomainClass implements Comparable
      {
      int number
      int compareTo(obj)

      { return this.number - obj.number }

      }

      sublevel1==sublevel2 calls the compareTo function for evaluation

      Attachments

        Activity

          People

            Unassigned Unassigned
            mbrianwhite Brian White
            Votes:
            4 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: