Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-696

Deprecate ClassUtils getShortClassName in favor of Class getSimpleName

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.6
    • Discussion
    • lang.*
    • None

    Description

      Added two null-safe ClassUtils.getSimpleName() APIs.

      ---------- Forwarded message ----------
      From: Gary Gregory <garydgregory@gmail.com>
      Date: Mon, Apr 11, 2011 at 10:18 AM
      Subject: [Lang] ClassUtils getShortClassName != Class getSimpleName
      To: Commons Developers List <dev@commons.apache.org>

      Hi All:

      Should we deprecate ClassUtils getShortClassName in favor of Class getSimpleName?

      The behavior of getShortClassName is undocumented for arrays in the Javadoc and is different from getSimpleName.

      When I replace the guts of getShortClassName to call getSimpleName, one test fails:

      junit.framework.ComparisonFailure: null expected:<[ToStringStyleTest.]Person[name=John Q. ...> but was:<[]Person[name=John Q. ...>
      at junit.framework.Assert.assertEquals(Assert.java:81)
      at junit.framework.Assert.assertEquals(Assert.java:87)
      at org.apache.commons.lang3.builder.ShortPrefixToStringStyleTest.testPerson(ShortPrefixToStringStyleTest.java:86)

      For now, I've made a note in the Javdoc to consider using getSimpleName.

      Attachments

        Issue Links

          Activity

            People

              ggregory Gary D. Gregory
              ggregory Gary D. Gregory
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h
                  1h