Groovy
  1. Groovy
  2. GROOVY-2503 MOP 2.0 design inflluencing issues
  3. GROOVY-1765

The equality and relational operators can not be overridden by a Category method

    Details

    • Type: Sub-task Sub-task
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.0
    • Fix Version/s: None
    • Component/s: groovy-runtime
    • Labels:
      None
    • Environment:
      Windows/XP service pack 2, Sun Java 1.6.0

      Description

      The equality and relational operators (==, !=, <=>, >, >=, <, and <=) can not be overridden by a Category method. Though a direct call to the equals() or compareTo() methods does use the Category method (except for the Number.compareTo(Number) case which does not call the Category method).

      It would be desirable to support overriding of the equality and relational operators, both for completeness and utility's sake. This would complement the ability to override the mathematical operators (i.e. +, -, *, /, etc.) via Category methods. In particular it would allow the comparison of object types where the equals() and compareTo() methods don't directly support the desired type combinations.

      The included category and test demonstrates some of the cases in question. The OperatorCategoryTest class contains tests that demonstrate successful uses and failing ones.

        Issue Links

          Activity

          Steve Hanmann created issue -
          Paul King made changes -
          Field Original Value New Value
          Link This issue relates to GROOVY-2756 [ GROOVY-2756 ]
          Jochen Theodorou made changes -
          Parent GROOVY-2503 [ 61571 ]
          Issue Type Bug [ 1 ] Sub-task [ 7 ]
          Jochen Theodorou made changes -
          Component/s groovy-runtime [ 16250 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
          Mark Thomas made changes -
          Workflow jira [ 12730887 ] Default workflow, editable Closed status [ 12742796 ]
          Mark Thomas made changes -
          Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
          Mark Thomas made changes -
          Workflow jira [ 12969144 ] Default workflow, editable Closed status [ 12976779 ]

            People

            • Assignee:
              Unassigned
              Reporter:
              Steve Hanmann
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:

                Development