Un-encapsulate refactoring in Eclipse or Intellij?
eclipse, intellij-idea, java, refactoring
Solution
- Write your new `getC()` method.
- Rewrite `getX()` to be `return getC().getX()`.
- Inline `getX()`.
The same goes for `y`.
Problem
Consider a wrapper class `W`, wrapping `C`, this meaning that for most attributes of `C`, there is a correspondent attribute `A` on `W`, its logic consisting in nothing more than delegation to `C`'s `A`. This situation can be most precisely depicted with the sketch shown below: ``` class W { private C c; getX() { return c.getX(); } getY() { return c.getY(); } } ``` The trouble is that I've decided that I wan't to get rid of `getX()`, and I'd prefer to either as a transitory step to put `C c` as public, having all the calling code of `W` do a `w.c.getX()` or `w.c.getY()` or alternatively to put create a `W.getC()`, and have all calls to `getX()` and `getY()` go through it. What this all boils down is to an "un-encapsulate" refactoring. Is there anything performing this much needed task either in Eclipse or Intellij?