Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to refactor a top-level class or interface to an inner one in Eclipse?

I have an interface that I want to move inside another type. Is there any way to get Eclipse to help me make that change? The same change could also be applied to a class to move it inside another.

Basically, I'm looking for the reverse of Convert Member Type to Top Level. I hoped it would be Move, but that only offers packages as targets.

like image 924
rjrjr Avatar asked Feb 16 '11 19:02

rjrjr


1 Answers

  1. Cut the Interface and paste it into the class where you want to embed it
  2. Add the static keyword if the inner class should be reachable without an instance of the outer class.
  3. In the Package Explorer, select your project and right click > source > organize imports

I think this will get most, if not all, of the compilation errors.

like image 165
Tim Bender Avatar answered Oct 16 '22 10:10

Tim Bender