[jdom-interest] why did you change Element.addContent?
rossi at cs.unibo.it
Wed Mar 10 02:08:33 PST 2004
Jason Hunter wrote:
> Alex Rosen wrote:
>> There was some talk of changing it back, because the benefit of the
>> Parent notion was not worth the cost in broken code. Jason, what did
>> you decide on this?
> Nothing yet. This is in fact the thing I pondered during my morning
> shower. :-)
> The problem is Java 1.4 and earlier doesn't have covariant return types,
> meaning an overridden version of a method can't return something more
> specific than the parent version.
Yes, but you can add new methods. I agree that addContentAndGetElement
sounds horrible (maybe addContentToElement is better) but it is
infinitely better than using casts everywhere in your code (which is
something that breaks up static type checking).
Of course I can extend Element on my own and add all the methods I want
(which is what I'm gonna if the API does not change).
More information about the jdom-interest