JDK-4034117 : Switch statements on classes
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 1.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1997-02-24
  • Updated: 1997-12-17
  • Resolved: 1997-12-17
Related Reports
Duplicate :  
Description

Name: mc57594			Date: 02/24/97


I want to use the object type as the case label.

Fantasy:
======

class abc{}
class a extends abc{};
class b extends abc{};
class c extends abc{};

public void myProc(abc p_abc){
  switch(p_abc){
    case a: ;
    case b: ;
    case c: ;
  }
}

I was implementing this by using method overriding like the following

Reality
=====

abstract class abc{
  abstract public void myProc();
}
class a extends abc{
  public void myProc() { }
};
class b extends abc{
  public void myProc() { }
};
class c extends abc{
  public void myProc() { }
};

public void myProc(abc p_abc){ p_abc.myProc(); }

So the inheritance does the selection. Since this is so mechanical I thought perhaps you could automate it. Clearly it would be valuable in all the atction handler stuff.
company - Seagate Software IMG , email - ###@###.###
======================================================================

Comments
WORK AROUND Name: mc57594 Date: 02/24/97 ======================================================================
11-06-2004

EVALUATION Duplicate of another unnecessary RFE. gilad.bracha@eng 1997-12-17
17-12-1997