For the sake of brevity I moved everything into this one code block and removed all comments and package/import statements.
The issue that I'm having is that I get a compiler error on "System.out.println(s.doWork(Main.spool()));"
The reason is taht doWork is specified to take either an Ajax/Download/Managed type but the return type of Main.spool() is of the subtype.
I thought that it would take the most specified return type for the overloaded functions. How do I do this w/o having to do some crazy if/switch statement?
Sorry if this is really silly but this is how I thought it would work.
Paul Clapham wrote:I would say your design is wrong. If you have something which should work differently for each subtype of a certain parent, then that's a sure sign you should be using inheritance and polymorphism. In other words, it's the Renderable class (or interface?) which should declare the doWork() method and each of the subtypes should implement that method in the way appropriate for that subtype.
I would agree but at some point all of these types will have to converge. Some will turn into strings and others will be turned into binary that a user can download. So I'm not sure as to how to get that piece to work. Design-wise that is.