I have a number of collections of classes which I need to refactor into new classes. I'm using Java with either Eclipse or Netbeans. Currently I create the new class FooList with a delegate List<Foo> and then follow all the places where the code fails to compile. Is there a way to do this without breaking the code (and preferably a single operation)?
EDIT I have the following type of construct:
public static List<Foo> Bar.createFooList(String s)
and List<Foo>
gets used frequently elsewhere and it makes sense as a business object FooList
. I have done this manually by:
public class FooList {
private List<Foo> fooList;
public FooList(String s) {
createList(s);
}
private void createList(String s) {//...}
public int size() {return fooList.size();}
}
FooList will also have methods beyond List. For example the present:
Bar.normalize(List<Foo> fooList);
would then become
fooList.normalize();
Where another function needs the methods of List I used the Source|Generate Delegate Methods option in Eclipse to generate those methods in FooList (as with size() above).
I can see the attraction @JonSkeet of implementing List<Foo> but I can't see how to change all my code automatically.