I\'m working on a problem where there are several implementations of Foo, accompanied by several FooBuilder\'s. While Foo\'s share sev
Having found this excellent answer I am now sharing it around.
public class SuperClass
{
@SuppressWarnings( "unchecked" ) // If you're annoyed by Lint.
public I doStuff( Object withThings )
{
// Do stuff with things.
return (I)this ; // Will always cast to the subclass. Causes the Lint warning.
}
}
public class ImplementationOne
extends SuperClass
{} // doStuff() will return an instance of ImplementationOne
public class ImplementationTwo
extends SuperClass
{} // doStuff() will return an instance of ImplementationTwo