Question: Can eclipse do this refactoring?

Say I have a class that has a List: 

```
class DomainObject {
    private List list;
    public List getList() { return list; }
}

```

Then some code that uses the class needs to do this:

```
domainObject.getList().get(23);

```

I'd like to refactor to this (and have all other references do the same):

```
domainObject.get(23);

```

I've tried a few options but can't seem to find a way of doing this (other than manually)

Answer: 
Try this:

1. Let `DomainObject` correctly implement `List` (using `list` as a delegate)
2. Let `getList()` return `this`
3. Refactor-Inline `getList()`
4. Optionally, remove `"implements List"` again keeping the `get()` method

Another (simpler) option:

1. Refactor-Rename `getList()` to `getMyListWithAUniqueNameAcrossTheProject()` (let Eclipse update all references)
2. Search-replace `"getMyListWithAUniqueNameAcrossTheProject()."` by `""`
3. Add and implement `DomainObject.get(int)`
I think what you want is *Refactor -> Introduce indirection...*. I am not really sure how to use it though, I think you must call that on `List.get`, specifying you want to create the method in `DomainObject`...

I tried here but eclipse takes a lot of time for computing it (looking for all references to that method I guess)

**edit**: I found [an article on the subject](http://www.eclipse.org/articles/article.php?file=Article-Unleashing-the-Power-of-Refactoring/index.html), which makes me think this might not be exactly what you want. However if Eclipse is smart enough it won't declare the method as static I guess. It still hasn't finished here, but I found [Bug 187227 Introduce Indirection is extremely slow](https://bugs.eclipse.org/bugs/show_bug.cgi?id=187227) which is due to the fact the method name on which it applies is very common, so I guess it is not usable in the case of `List.get`…