Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-17086

Introduce ResolvableType.toClass() shortcut

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: None
    • Fix Version/s: 5.1 RC1
    • Component/s: Core
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      With a ResolvableType argument coming into a method, there is often a need to use it as a Class, e.g. for basic assignability checks or for comparison purposes. Let's introduce a Resolvable.toClass() method which serves as a convenient non-null shortcut for resolve(Object.class) (since the basic resolve() method is nullable, a fallback has to be specified, and we can simply assume Object.class as fallback for toClass()).

      For many purposes, this is also an alternative to ResolvableType.getRawClass(): non-null and also taking resolved top-level type variables into account. However, if code wants to actually check the top-level raw type in a parameterized arrangement, e.g. expecting a fixed outer collection declaration, then getRawClass() remains the right method to use, typically skipping non-null results from it.

        Attachments

          Activity

            People

            Assignee:
            juergen.hoeller Juergen Hoeller
            Reporter:
            juergen.hoeller Juergen Hoeller
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              3 years, 29 weeks, 6 days ago