A DESCRIPTION OF THE REQUEST :
Allow any object to implement "Switchable," exposing particular required functions necessary for the compiler to make calls and switch against the object.
Better yet, take this process one step further and allow for extensible auto-boxing using an implementing Interface to define auto-boxing behavior.
JUSTIFICATION :
Handling of switchable objects is too "special case" with handling of very specific object types in an inflexible manner. This runs contrary to the object-oriented and extensible nature of Java.
By providing a "Switchable" interface, any object can be enhanced for utilization within a switch statement. Change Number and Enum to implement/extend this interface as necessary.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Have any object be able to implement "Switchable" interface, which forces implementation of a function which returns an integer-compabitible type necessary for switching. Any "Switchable" should be capable of being utilized within a switch statement.
---------- BEGIN SOURCE ----------
Handling of switchable objects is "special case" with handling of very specific primitives and object types in an inflexible manner. The behavior is "hard-coded" and inflexible.
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No known workaround which can still utilize switch statements.