I frequently write code where I say
public class MyClass
{
public static MyClass makeOne(some parameters) {
MyClass mc=new MyClass();
... various manipulations to populate the class ...
}
... etc ...
}
But then I may subtype this class, or cut-and-paste the code to another class, and if so I have to change all the occurrences of the class name to the new class.
What I'd really like to do is something like
public class MyClass
{
public static <T> makeOne {
<T> one=new <T>();
... various manipulation to populate the class ...
}
... etc ...
}
I'm using the notation of generics (sort of), but I don't mean to imply that it can be done with generics or that it would look anything like that.
Is there a way to do this?