Velocity
  1. Velocity
  2. VELOCITY-350

Base Equality on toString() when operands are of different classes

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 1.5
    • Component/s: Engine
    • Labels:
      None
    • Environment:
      Operating System: Windows XP
      Platform: PC

      Description

      This was discussed on the dev list a few weeks ago. If two objects being
      compared are of different (non-numeric) classes, I'd like to see equality be
      based on toString (rather than just be false). This just makes sense in a
      template environment where types are not visible to template writers, and is
      also the way that JSTL/JSP 2.0 works. This is particularly useful when
      comparing a literal String to a class implementing Bloch's Typesafe
      Enumeration pattern [1] or a StringBuffer.

      Comments welcome.

      [1]
      http://java.sun.com/developer/Books/shiftintojava/

        Activity

        Hide
        Will Glass-Husain added a comment -

        Discussion on dev list. From Nathan Bubna:

        > 1. if foo and bar are both numbers, do a numeric comparison.
        > 2. if foo and bar are strings, do a direct string comparison
        > 3. if bar is an instance of foo's class and/or foo is an instance of
        > bar's class, then do foo.equals(bar)
        > 4. otherwise, compare foo.toString() with bar.toString()

        Show
        Will Glass-Husain added a comment - Discussion on dev list. From Nathan Bubna: > 1. if foo and bar are both numbers, do a numeric comparison. > 2. if foo and bar are strings, do a direct string comparison > 3. if bar is an instance of foo's class and/or foo is an instance of > bar's class, then do foo.equals(bar) > 4. otherwise, compare foo.toString() with bar.toString()
        Hide
        Will Glass-Husain added a comment -

        I've gone ahead and added this. We still need a doc patch, so I'm leaving this open.

        Show
        Will Glass-Husain added a comment - I've gone ahead and added this. We still need a doc patch, so I'm leaving this open.
        Hide
        Will Glass-Husain added a comment -

        updated docs.

        Show
        Will Glass-Husain added a comment - updated docs.
        Hide
        Henning Schmiedehausen added a comment -

        Close all resolved issues for Engine 1.5 release.

        Show
        Henning Schmiedehausen added a comment - Close all resolved issues for Engine 1.5 release.

          People

          • Assignee:
            Unassigned
            Reporter:
            Will Glass-Husain
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development